I'm confused - if the second argument to newSVpv() is 0 then it calculates the length for you (so long as it is a NULL terminated string )? Is this not what you want?
Cheers. On Wed, Oct 02, 2002 at 03:21:27PM +1000, Sisyphus wrote: > > ----- Original Message ----- > From: "Kyle R . Burton" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, October 02, 2002 1:24 PM > Subject: Re: Return a string to perl > > > > > > SV* rv = newSVpv( to_string( struct ) ); > > > > > > Sorry - I assumed that would work - but now that I come to check it, I think > that 'newSVpv()' requires a second (strlen) argument. > > > > > I don't know what the return value of to_string() is. If it's a char*, > > then the above should work - or pushing newSVpv( to_string( struct ) ) > onto > > the return stack should work. > > > > I assume it's a char*. (It's certainly not an SV*.) > As I mentioned in my first post, I can allocate a char* buffer and do: > buffer = to_string(struct); > Then push it onto the stack as an 'SVpvn(buffer, strlen(buffer))'. But, like > you've been telling me, why not just put the damn thing into an SV* and > return it. > > Seems that if I want to use SvPV_nolen(), then its argument has to be an > SV*. > And if I'm trying to pass a char*, then I can't escape having to provide its > 'strlen()'. > > Snookered on that one ... for the moment :-) > > Cheers, > Rob
