Freeing arrays
Manuel M. T. Chakravarty
chak at cse.unsw.edu.au
Mon Apr 8 02:28:30 EDT 2002
George Russell <ger at tzi.de> wrote,
> According to section 5.8 of the spec, MarshalAlloc.free will "free a block
> of memory that was allocated with malloc or mallocBytes". Fine. But will it
> also free blocks of memory allocated by MarshalArray.mallocArray and friends?
Yes, `mallocArray' is just a wrapper around `mallocBytes'.
> Come to think of it, what about MarshalArray.reallocBytes?
That can be free'd with `MarshalAlloc.free', too.
> Also, what is
> the "realloc" function mentioned in the specification of reallocArray, or do you
> mean reallocBytes?
Yes, `rallocBytes' is meant, but thinking about it, we might
actually add a function:
realloc :: Storable b => Ptr a -> IO (Ptr b)
I think, it is more orthogonal this way. Any objections?
Cheers,
Manuel
PS: I'll make sure that these points are clarified in the
FFI spec.
More information about the FFI
mailing list