I'll repeat my previous advice. Don't use T_OBJPTR. Instead, have your XS code deal with very simple C data types and do all of the object creation/destruction in wrapper methods written in Perl (as part of your module).

The reason I advise this is exactly because XS code is so easy to get wrong and so hard to debug.

sub new { my $ptr= xs_new( ... ); bless \$ptr, ...; } sub DESTROY { my $self= shift(@_); xs_free( $$self ); }
and
int xs_new( ... ) WHATEVER* pObj= ...; RETVAL= (int)pObj; void xs_free( self ) int self CODE: free( (void *)self );

                - tye

In reply to Re: panic: leave_scope inconsistency. (need help creating Tie::PureDB) (less XS) by tye
in thread panic: leave_scope inconsistency. (need help creating Tie::PureDB) by PodMaster

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.