Skip Menu |
Report information
Id: 132964
Status: new
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: pali [at]

Operating System: (no value)
PatchStatus: (no value)
Severity: low
Type: unknown
Perl Version: (no value)
Fixed In: (no value)

Date: Mon, 12 Mar 2018 10:59:55 +0100
To: perlbug [...]
Subject: Missing newSVsv_nomg macro variant
From: pali [...]
Download (untitled) / with headers
text/plain 1.7k
Hi! In perl XS api is missing function which creates a copy of the scalar without processing get magic and without destroying source scalar when is mortal. It is needed in situation when you want to call other perl function (via call_pv()) with scalar argument which comes from the argument passed to the current XS function (e.g. ST(0)) on which was already called SvGETMAGIC() and it is needed to prevent modification of it argument (e.g. because it is used also after call_pv() call). Table of available functions: magic steal mortal target source source target sv_setsv() X X sv_setsv_mg() X X X sv_setsv_nomg() X SvSetMagicSV() X X X SvSetMagicSV_nosteal() X X SvSetSV() X X SvSetSV_nosteal() X sv_mortalcopy() X X X newSVsv() X sv_setsv_flags() CAN CAN CAN Function which would create a copy of the scalar without processing get magic and without destroying (stealing) source scalar can be caller newSVsv_nomg() (according to to other _nomg names). Primitive implementation is there: static SV *newSVsv_nomg(SV *sv) { SV *ret = newSV(0); sv_setsv_flags(ret, sv, SV_NOSTEAL); return ret; } For above case with call_pv() can be useful function like newSVsv_nomg(), but which would return mortal copy. Based on above used naming scheme, I would propose sv_mortalcopy_nosteal_nomg(). Primitive implementation: static SV *sv_mortalcopy_nosteal_nomg(SV *sv) { SV *ret = sv_newmortal(); sv_setsv_flags(ret, sv, SV_NOSTEAL); return ret; } Please consider implementing these two functions into perl.h/perlapi.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at