Freeing arrays

Manuel M. T. Chakravarty chak at
Mon Apr 8 02:28:30 EDT 2002

George Russell <ger at> wrote,

> According to section 5.8 of the spec, 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 `', 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?


PS: I'll make sure that these points are clarified in the
    FFI spec.

More information about the FFI mailing list