Thanks Marc,
In my poking about I did notice that post, but it uses a macro. H'mmm... at this early stage I'm afraid I'm still living in imperative land :-| I think there's a long way to go to reach macro heaven. Right now just making it out of imperative land into functional land is pretty tough. One day, perhaps, I'll make it through the pearly gates into macro heaven!
Thanks again for helping me out.
Cheers,
Rob.
---- Marc Feeley feeley@iro.umontreal.ca wrote:
As far as I can tell it is memory safe. However, it might be simpler to put your free_point function as a release function on the Sstruct* foreign type. That way the free_point function will be called by the Gambit garbage collector when the Scheme program no longer has a reference to a given structure. If it is possible for your C code to keep pointers to your structure, then it will be convenient to use ___alloc_rc instead of malloc, that way you can increment the reference count in that structure to prevent the garbage collector from freeing the structure.
All of these issues can be abstracted in a macro for defining foreign structures. This is explained in the following message:
https://mercure.iro.umontreal.ca/pipermail/gambit-list/2009-May/003475.html
Marc