Foreign.Marshal.Alloc questions

Simon Marlow simonmarhaskell at gmail.com
Thu Aug 10 06:26:10 EDT 2006


Chris Kuklewicz wrote:
> For the allocation functions in Foreign.Marshall.Alloc, are the function 
> contracts that return new pointers such that the pointers are never 
> nullPtr, or is it prudent to always check the new ptr?

Yes, the result of mallocBytes (for example) is never NULL.  If the allocation 
fails, an exception is raised.

> I can see on GHC than allocaBytes uses newPinnedByteArray# but I have 
> not tracked down the source file for that to read it.

newPinnedByteArray# is a GHC primitive.  It is implemented in C--, so you won't 
find it in a Haskell source file anywhere.

Cheers,
	Simon


More information about the Glasgow-haskell-users mailing list