foundation
foundation copied to clipboard
Add alloca and malloc
How to allocate memory and pass the ptr to foreign C code using foundation ?
you can use base's alloca and malloc functions. The Ptr type is the same.
You should be able to use the two following lines together without issues:
import Foreign.Marshal.Alloc (alloca, malloc)
import Foundation.Class.Storable
And for foreign pointer, you can do more or less the same.
Importing alloca and malloc from base directly does work.
But we still can't use the alloc and malloc to do allocation if we only have made our custom type as the instance of foundation's Storable without the instance of base's Storable. Is there any plan for providing allocate functions for foundation's Storable ?
ha I see. Ok, good point. Now there is a plan !