That's easy, but in this case you must work not with SV but refernce to SV, and dereference it properly.
Let us start with perl stub of what you're trying to achieve
sub test { my $ref = shift; $$ref .= shift; # concatenate, but do efficiently at C level, workin +g with preallocated space }
If this is not what you need, then try expressing in terms of Perl sub your ideas, and we'll translate those to XS... or C.
When you enter a sub, parameters to it are mostly copied (well, sometimes they are aliased but relying on this knowledge will not help you understanding, so let us assume they are copied), so you will not gain speed unless you work with reference.
Regarding your OP code, when you make an illusion of correctly working code, but with mystery "Why do I need to increment the ref count?" this only means you got a SV leak. I can explain it, if needed.
PS sorry my frustrated reply, but once you'll explain your subroutine better I will reply better :)
In reply to Re^5: XS/Inline::C concat *any* two SVs.
by vkon
in thread XS/Inline::C concat *any* two SVs.
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |