newCString -- to 'free' or not?

Bayley, Alistair Alistair_Bayley at
Mon Sep 27 03:37:17 EDT 2004

There are some useful guidelines hidden in section 8.2.3 of the GHC user's
And Alistair Reid answers a similar question I asked:
(Common Problems: Are Ptr values deallocated?)

In the current CVS code newCString redirects to newCAString, which uses
mallocArray (or newArray), and which also states that storage must be freed:

You can also see that uses malloc:

> -----Original Message-----
> From: Peter Simons [mailto:simons at] 
> Sent: 25 September 2004 21:38
> To: glasgow-haskell-users at
> Subject: newCString -- to 'free' or not?
> When I create a CString with Foreign.C.String.newCString, do
> I have to 'free' it after I don't need it anymore? Or is
> there some RTS magic taking place?
> How about and all those other
> newXYZ functions? 
> Peter

Confidentiality Note: The information contained in this 
message, and any attachments, may contain confidential 
and/or privileged material. It is intended solely for the 
person(s) or entity to which it is addressed. Any review, 
retransmission, dissemination, or taking of any action in 
reliance upon this information by persons or entities other 
than the intended recipient(s) is prohibited. If you received
this in error, please contact the sender and delete the 
material from any computer.

More information about the Glasgow-haskell-users mailing list