
23 Dec
2014
23 Dec
'14
6:19 a.m.
On 23 December 2014 at 08:10, Yuras Shumovich
Looks like you need 'unsafePackCStringFinalizer' (or one of it's variants) from Data.ByteString.Unsafe module. It lets you reuse the buffer and deallocate it in finalizer. Something similar is used e.g. in 'kyotocabinet' package.
I tried using this, but it seems like the pointer created by mallocForeignPtrBytes is freed as soon as it is no longer referenced (upon returning from the function). Then, later, when the bytestring is finalized, the pointer is freed again causing an abort on double-free. How do I "transfer" ownership of the pointer? -- mithrandi, i Ainil en-Balandor, a faer Ambar