Muppet <[EMAIL PROTECTED]> writes: >Steve Hay said: >> So: I've entrusted managemnt of foo's memory to Perl by placing it in >> the SV, but I still have to free up anything else that was allocated and >> is pointed to from within foo. Is there any way to have Perl free the >> members of foo when it frees foo, so that the whole struct is freed >> instead of just the outer bit? > >if it's a blessed SV, so you can set up a DESTROY method. otherwise, you'll >need to use a magic virtual table. it's described in perlguts ('Magic >Variables') and the Embedding and Extending Perl book.
Tk does exactly this kind of thing, to create "objects" for XEvent structs, as it is an object it cleans up by blessing. I think I have used the vtable trick as well.