This reminds me that Gambit provides a memory allocation function, ___alloc_rc,
for allocating C objects on the C heap which have a back-pointer to a Scheme object, and also a reference count. The API is:
void *___alloc_rc(unsigned long n); void ___release_rc(void *ptr); void ___addref_rc(void *ptr); void ___set_data_rc(void *ptr, ___SCMOBJ val); ___SCMOBJ ___data_rc(void *ptr);
This might be just what I need, thanks! Paradoxically enough, I was allocating my structs with ___alloc_rc, but I don't think I really understood how that works.
I'll ping the list when I have something that I believe is solid, and/or I'll put it in the dumping grounds, just in case it might be of use for anyone else.
Thanks again,
Estevo.