On Sun, Aug 15, 2004 at 10:14:22PM +0200 Tels wrote:

> Back to the difference between void and SV*:
> 
> The last lines of my original routine, with a void return type:
> 
>     temp = *av_fetch(a, 0, 0);          /* fetch first element */
>     ST(0) = boolSV((SvIV(temp) == 0));
> #line 554 "FastCalc.c"
>     }
>     XSRETURN(1);
> }
> 
> The same with RETVAL and OUTPUT: section:
> 
>     temp = *av_fetch(a, 0, 0);          /* fetch first element */
>     RETVAL = boolSV((SvIV(temp) == 0));
> #line 582 "FastCalc.c"
>         ST(0) = RETVAL;
>         sv_2mortal(ST(0));
>     }
>     XSRETURN(1);
> }
> 
> 
> See the sv2mortal(ST(0)); there? :) I think it doesn't hurt, but it 
> certainly is not neccessary, since everything works fine without it.

It sort of always 'works' without mortalizing the return values. But you
may end up accumulating values that wont ever get freed.

As for the case above, it's somewhat special. boolSV() returns either
&PL_sv_no or &PL_sv_yes and those two aren't subject to refcounting.
Mortalizing them, however, wont do any harm fortunately.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval

Reply via email to