On Mon, Jan 08, 2007 at 10:39:57AM -0800, Marvin Humphrey wrote:
> 
> On Jan 8, 2007, at 10:26 AM, Nicholas Clark wrote:
> 
> >>Am I doing something wrong? Maybe because of refcounts and such?
> >
> >Yes, I think so. (But I'm not the expert on these)
> 
> ---->8 snip 8<----
> 
> >     RETVAL = sv_2mortal(newRV_noinc((SV*)array));
> 
> /me .oO( wow, how often do you get to correct Dr. Clark? )

Oh, quite often when it's about XS, I suspect :-)

I know I don't know it. If I need to deal with it I first look at the C code
that xsubpp has generated.

> The OUTPUT: apparatus will mortalize RETVAL for you.  Here's a  
> snippet from a generated C file.
> 
>     RETVAL = newRV_noinc(target);
> }
> #line 1516 "lib/KinoSearch.c"
>     ST(0) = RETVAL;
>     sv_2mortal(ST(0));
>     }
>     XSRETURN(1);
> 
> So, you shouldn't mortalize RETVAL yourself.

Ah right.

So it's not that simple :-(

Nicholas Clark

Reply via email to