Syntactic Confectionery Delight | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
First, I want to thank everyone for your great replies! I really learned a lot from reading what was written here. Okay, so I've tried to absorb what I read, and now my XS code looks something like this:
I have incorporated the advice of Elian here, tye here, and pg here. I am manipulating the return stack myself, only returning the buffer (the caller can call length), and I'm checking the malloc() return value, and returning undef if it fails. my_func() returns the number of bytes written to tmp_buffer, which is guaranteed to be less than len, so the line that NULL-terminates the buffer should be safe, unless my_func() seriously misbehaves. And I'm using that value for the second argument to newSVpv() instead of zero... Any new critiques or comments? Does it look better? Thanks, In reply to Re: Perl XS: garbage-collecting my malloc'd buffer
by edan
|
|