
There are some useful guidelines hidden in section 8.2.3 of the GHC user's guide: http://www.haskell.org/ghc/docs/latest/html/users_guide/sec-ffi-ghc.html#AEN 10578 And Alistair Reid answers a similar question I asked: http://www.reid-consulting-uk.ltd.uk/docs/ffi-Common_Problems.html (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: http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/libraries/base/Foreign/C/S tring.hs?rev=1.14 You can also see that Foreign.Marshal.Utils.new uses malloc: http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/libraries/base/Foreign/Mar shal/Utils.hs?rev=1.12
-----Original Message----- From: Peter Simons [mailto:simons@cryp.to] Sent: 25 September 2004 21:38 To: glasgow-haskell-users@haskell.org 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 Foreign.Marshal.Utils.new 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. *****************************************************************