Hello everyone,

I want to call a perl constructor, which also calls die (with the
object). For example, in perl code:

       MyClass->Raise($err_code, $err_string);

Now, the question is whether the following code would leak memory
(under mod_perl) or work as intended. In other words, if the sub calls
die (the intended effect), will the temporaries still get cleaned up
in a persistent environment such as mod_perl?

void my_c_func(int err_code, char *err_string)
{
       dSP;

       ENTER;
       SAVETMPS;

       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv("MyClass", 0)));
       XPUSHs(sv_2mortal(newSViv(err_code)));
       XPUSHs(sv_2mortal(newSVpv(err_string, 0)));
       PUTBACK;

       call_method("Raise", G_DISCARD);

       FREETMPS;
       LEAVE;
}

I also have one more unrelated question: Using SvPV(sv, len) on a
unicode string, len is guaranteed to be the byte length, not unicode
length, right?

By the way, I have read perlcall, perlguts and perlxs and related documentation.

Thank you for your time.


Best Regards,

Christian

Reply via email to