I don't have a lot of complicated Perl XS experience, but I can give this
a shot because I've run into a similar problem myself.
Kort, Eric <[EMAIL PROTECTED]> writes:
> My problem is that the inline'd xsub (copyImage) works once, works a
> second time, but then upon being called the third time my screen fills
> with "Attempt to free unreferenced scalar" warnings.
When I ran into this before, it was because I'd not correctly handled the
reference counts when passing variables into a Perl sub. It turned out
that I was "leaking" one reference count each time my code ran, so
eventually the reference count went to zero despite the fact that the
variable was still in use.
I fixed it by finding a place I should have been incrementing and wasn't.
I'm not familiar at all with the Inline module, but is this return:
> //now get a reference to the copied array and return it
> svPtr_arrayRef = newRV_noinc(avPtr_filteredImage);
> return svPtr_arrayRef; // return the reference
> }
doing the normal Perl magic stuff? In other words, is this doing
something like:
ST(0) = sv_2mortal(svPtr_arrayRef);
XSRETURN(1);
If so, isn't the Perl code going to expect the reference to have
incremented the reference count of the array that it points to? In other
words, why were you using newRV_noinc() here instead of newRV_inc()?
I could be on completely the wrong track, in which case maybe I'll learn
something new too. :)
--
Russ Allbery ([EMAIL PROTECTED]) <http://www.eyrie.org/~eagle/>