Florian Ragwitz
2006-08-07 17:38:07 UTC
Hello there,
I wrote bindings for a small C library using XS. In those bindings I map
some c structures to a perl objects, which are blesed into
"Audio::XMMSClient".
The new() method allocates a new c structure structure and my bindings
wrap it into an object. Now I'd like to free the memory allocated in
new() when the perl object isn't used anymore.
DESTROY seems to be the way to do that. So I defined a DESTROY method in
my XS code:
void
DESTROY(c)
my_c_structure_t* c
CODE:
my_c_structure_unref(c);
Unfortunately DESTROY won't be called when the perl objects reference
count reaches zero as it seems to be the case in pure-perl world. What's
the difference between pure-perl code and XS code with regard to
DESTROY? How can I get my XS DESTROY method called properly?
TIA,
Flo
I wrote bindings for a small C library using XS. In those bindings I map
some c structures to a perl objects, which are blesed into
"Audio::XMMSClient".
The new() method allocates a new c structure structure and my bindings
wrap it into an object. Now I'd like to free the memory allocated in
new() when the perl object isn't used anymore.
DESTROY seems to be the way to do that. So I defined a DESTROY method in
my XS code:
void
DESTROY(c)
my_c_structure_t* c
CODE:
my_c_structure_unref(c);
Unfortunately DESTROY won't be called when the perl objects reference
count reaches zero as it seems to be the case in pure-perl world. What's
the difference between pure-perl code and XS code with regard to
DESTROY? How can I get my XS DESTROY method called properly?
TIA,
Flo
--
BOFH excuse #41:
interrupt configuration error
BOFH excuse #41:
interrupt configuration error