[Haskell-cafe] FFI Query: How to free a CString allocated in Haskell

Peter Gammie peteg42 at gmail.com
Tue Apr 29 02:38:33 EDT 2008


On 29/04/2008, at 12:58 PM, Brandon S. Allbery KF8NH wrote:

> On Apr 29, 2008, at 1:45 , Verma Anurag-VNF673 wrote:
>> A naïve question I have now after reading your mail. How do I call  
>> MarshallAlloc.free from my C code because that's where I need to  
>> free it?
>
> Provide a Haskell wrapper function to deallocate / free it, as a  
> parallel to the function that allocates and returns it to the C code.

I would also point out the existence of withCString and friends. Tread  
carefully if you care about Unicode!

cheers
peter



More information about the Haskell-Cafe mailing list