Independent of what specific behavior is required, it still seems like
the original code ought to "work" with respect to ref counting and
destruction. Except that I don't see your returned AV* being
mortalized anywhere. AV*'s and HV*'s are done incorrectly in the
default typemap, you know -- they should be mortalized, as SV*'s are,
but they unfortunately weren't in some ancient version of Perl and so
cannot be made to now without changing the API. They are a bloody
sacrifice to the gods of backwards compatibility.

Or at least, that was the case in Perl 5.8. I suppose it's possible
that 5.10 chose to unbreak that piece. I can't remember where it was
documented, so I can't quickly check.

I have an evil tendency to override the built-in typemap for AV* and
HV* with my own that does the mortalizing. Which makes inexperienced
XS coders who look at my stuff happy (err... not sad, to be precise),
and incents experienced XS coders to skin me alive and roll me in rock
salt.

Reply via email to