De: Mikael <mikael.rcv@gmail.com>
Para: gambit-list@iro.umontreal.ca; euccastro@yahoo.com
Enviadas: Segunda-feira, 26 de Março de 2012 6:03
Assunto: Re:
[gambit-list] References between 'foreign' objects.
Estevo, if this delivered for you, please remember to document this mechanism (___alloc_rc and the others) in the Wiki so it'll be clear also for others. Mikael
Den 25 mars 2012 04:02 skrev Estevo
<euccastro@yahoo.com>:
> 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.