Bingo. See below.
(snip)
> I was assuming that the use Inline bit was handling the magic
> of taking a
> C return value and translating it into a Perl stack return; is that
> correct?
That's correct.
(snip)
> The place where I was having this problem before was rather
> different than
> what you're running into; I was storing a value directly into
> a Perl SV
> from C code.
(snip)
> and if I left off the SvREFCNT_inc, IIRC, I was getting the
> same error.
Reading this jarred my memory...I remember seeing somewhere (and actually posting a question about this fact to c.l.p.m) that when you push an SV onto an array with av_push, you need to manually increment the reference count of the SV (it now exists both as an array element and as a plain SV). As I didn't do it, perl must have been trying to clean up the SV after the array was destroyed, and found its reference count was already zero.
So, when I did this:
for (iterate=0; iterate<262144; iterate++)
{
pixel = *av_fetch(avPtr_inputImage, iterate, 0);
av_push(avPtr_filteredImage, pixel);
(void) SvREFCNT_inc(pixel);
}
instead of this:
for (iterate=0; iterate<262144; iterate++)
{
av_push(avPtr_filteredImage, *av_fetch(avPtr_inputImage, iterate, 0));
}
The problem disappeared!
Thanks for your help.
Eric
