No, you can't get Perl to use buffers allocated by other librariesOh, sure you can. It's not that big a deal, though you need to mark the SV as readonly or throw some TIE magic on it to make sure the buffer doesn't go moving around without something being able to handle it. You need to be mildly careful to make sure the code's not too fragile, but that's about it.
As for complex XS code... It's always been my view that if you're bopping back and forth between C and perl, you're making a mistake. The XS code should handle everything it needs to, and should present a simple interface. Dealing with perl's stack, return values, hashes, and other things isn't at all difficult unless you make it so, and it's been my experience that trying to not do things in XS is the easiest way to make things far more difficult than you have to.
The C/perl boundary should be crossed only once, and the presented interface should be clean, proper, and perlish. Fear or dislike of XS or C is no reason to not do things properly, because to do so leads to messy and buggy code.
If you had to drop to XS, you might as well do it right, rather than do a half-assed hack job that you patch up in a wrapper perl routine.
In reply to Re: Re^4: Perl XS: garbage-collecting my malloc'd buffer (perlish?)
by Elian
in thread Perl XS: garbage-collecting my malloc'd buffer
by edan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |