in reply to XS-ive Mortality. (or when to use sv_2mortal())
Notice that foo1() specifically mortalises, while foo2() does not. Seems strange - but if you look at the C file that gets generated you'll see that the mortalisation got inserted into foo2() for you.use warnings; use Inline C => Config => CLEAN_AFTER_BUILD => 0, BUILD_NOISY => 1; use Inline C => <<'EOC'; void foo1 (int x) { Inline_Stack_Vars; Inline_Stack_Reset; Inline_Stack_Push(sv_2mortal(newSVuv(x * 3))); Inline_Stack_Done; Inline_Stack_Return(1); } SV * foo2 (int x) { return newSVuv(x * 3); } EOC print foo1(7), "\n", foo2(8), "\n";
|
|---|