Tanks guys, got it working.
SV *work(char *str){
char *ret, *ncp;
SV *perlRet;
ret = New(0, ret, retLen, char);
ncp = ret;
while(*cp){
// work with ncp and cp
*cp++;
}
*ncp = "\0";
perlRet = newSVpvn(ret, strlen(ret));
Safefree(ret);
return perlRet
}
This is currently working :).
However, an optimization could be done if I could avoid copying the
string I'm working on before returning it.
The strings passed in can be rather large, and this would be nice to
avoid allocating so much space.
I was thinking of something in the line of creating an SV of type pv
right away, and then using sv_2pvbyte_nolen to get the buffer.
I think this should work, but I can't find a newSVpv function that
allows me to specify the string length I want without passing in a
char *.
Any other suggestions?
BTW, the code also works with malloc / free :)
Paulo F. Andrade
[EMAIL PROTECTED]