> > > >   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.

You're correct, it does require a second argument.  If you read the
perlapi manpage (I just did), it says you can pass 0 [zero] as the
second argument and newSVpv will compute the length for you (by calling
strlen).

> 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.

If you're returning only 1 value and that value is a char*, then wrapping
the value in an SV* is exactly what Inline does automaticly for you.

> Seems that if I want to use SvPV_nolen(), then its argument has to be an
> SV*.

Yes, all of the Sv* macros require this.

> And if I'm trying to pass a char*, then I can't escape having to provide its
> 'strlen()'.

Perl doens't look at strings in the same way that C does.  It tracks the 
length explicitly because Perl allows its strings to contain nulls and any
other binary data - Perl's scalars [strings] are just byte arrays.  This
is why things probably seem a bit more rote then they would in C.  Of course
you also get the beneift of not having to recompute the length of the string
every time you operate on it.


Kyle

-- 

------------------------------------------------------------------------------
Wisdom and Compassion are inseparable.
        -- Christmas Humphreys
[EMAIL PROTECTED]                            http://www.voicenet.com/~mortis
------------------------------------------------------------------------------

Reply via email to