
How about making [&free] private in ForeignPtr? This change breaks the new library setup, because it gets MarshalAlloc from fptools but ForeignPtr from you. The alternative would be to duplicate ForeignPtr, but that would be a waste.
I think it logically belongs in the same module that provides malloc and free. Suppose we had two memory allocators, you'd have to be sure to use the right 'free' for each object and that free ought to come from that same place that provides the malloc you allocated with. (In my other life as an OS componentware hacker, we do sometimes have multiple mallocs and being sure to use the right one is a concern so this issue is very much in my mind.) I must admit that I don't quite understand how it broke things though... -- Alastair