----- Original Message ----- From: "Paulo Filipe Andrade" <[EMAIL PROTECTED]>
.
.

That's it. I got it working like the example above.
I just have a couple of questions more about memory leaks.

1 - If you create an SV like so:
outsv = newSV(lenX);
and then use SvCUR_set to set the string length
SvCUR_set(outsv, lenY);
where lenY < lenX.
When outsv is freed the whole buffer is still release right? SvCUR doesn't matter, right?

As far as freeing goes, you may be right.
But if you don't set set CUR it defaults to zero - which has disastrous effects on the PV that is actually being stored in the scalar.

It's not hard to test - just comment out the line 'SvCUR_set(outsv, len);' and you'll soon see :-)

2- Finally, do I need to call sv_2mortal on outsv before returning it?

No. If I do that I get an "Attempt to free unreferenced scalar..." warning.

Cheers,
Rob

Reply via email to