[Haskell-cafe] Re: Re[2]: heap lifetime question
Ben Franksen
ben.franksen at online.de
Sun Aug 10 17:33:31 EDT 2008
Galchin, Vasili wrote:
> that is what I thought .. especially after just looking at the
> implementation for alloca/allocaBytes. For me and others on thie group is
> there documentation on the ghc run-time model and also the run-time
> library architecture. Both would help/aid in reading the code and of
> course educate more people?
I'd rather use the FFI Addendum
(http://www.cse.unsw.edu.au/~chak/haskell/ffi/) as reference than the ghc
implementation. Section 5.8 "MarshalAlloc" says
alloca :: Storable a => (Ptr a -> IO b) -> IO b
Allocate a block of memory of the same size as malloc, but the reference is
passed to a computation instead of being returned. When the computation
terminates, free the memory area again. The operation is exception-safe;
i.e., allocated memory is freed if an exception is thrown in the
marshalling computation.
allocaBytes :: Int -> (Ptr a -> IO b) -> IO b
As alloca, but allocate a memory area of the given size. The same alignment
constraint as for mallocBytes holds.
Cheers
Ben
More information about the Haskell-Cafe
mailing list