in reply to Re^3: Need for (XS) speed
in thread Need for (XS) speed
And if you have a library already allocating the memory, you can even reuse it if you use the string approach. Create a reference to a blessed scalar, assign to the scalar's PV the block of memory you got from the library, and set its SvLEN to zero so Perl won't try to free it. You can free it properly from your destructor (thus the reason for blessing).