in reply to NEWSV'd scalar isn't initially empty?
Ah. On reading the perl source I think I should have written this thusly. This leaves off the upgrade and grow (that's apparently handled within NEWSV when len > 0) and since NEWSV uses New() instead of Newz(), I had to follow up with an explicit Zero() on the PV. So... is *this* right? I added a SvPOK_only() call as well because without that the only flag on it was TEMP. If I do my $foo = foo(); Dump($foo) the REFCNT is one - is that right and am I supposed to mortalize the scalar I'm returning here?
SV* foo(int nr) { SV* out = NEWSV(535,nr); SvPOK_only(out); Zero(SvPVX(out), nr, char); SvCUR_set(out,nr); return (out); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: NEWSV'd scalar isn't initially empty?
by mpeppler (Vicar) on Aug 05, 2003 at 09:01 UTC |