Derrik Pates <[EMAIL PROTECTED]> writes:
>I've been working on a wrapper for the netfilter/iptables library on Linux
>2.[34].x, and would like to take a particular approach in handling
>connection commit. However, I don't seem to be able to - the object is
>passed to its methods as a reference, and it seems that every time a
>method is called, the DESTROY method also gets called (obviously NOT what
>I'm looking for).
>
>Is the DESTROY method unusable? 

No it works fine.

>Is there any way to call a routine before
>final cleanup of an object 

That is what DESTROY does - Tk, DBI and other mainstream XS modules
depend on it working that way.

>that won't be called every time the handle is
>revised? Or am I looking at a lost cause?

You either have your REFCNTs in a mess (easy to do) so DESTROY is 
being called prematurely, or your typemap keeps creating 
"temporaries" which get DESTROYed.

One case to beware of is that the XS code :

void
SomeMethod(obj)
...

is to XSRETURN(1) - the void being a signal to xsubpp that _you_ 
will handle the return value - not that there isn't a return value.

if you have not assigned anything to ST(0) you will return 
your 1st arg (typically a mortal ref to the object) and then 
if method call is in a void context perl will free it.

-- 
Nick Ing-Simmons

Reply via email to