diff options
author | Nicholas Clark <nick@ccl4.org> | 2004-10-15 17:11:08 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2004-10-15 17:11:08 +0000 |
commit | 5fcdf167f4386a3583bf0db9d98b989639295a45 (patch) | |
tree | 196d537a9c2aae33aea4f0c2500053b34fc83295 | |
parent | 2cbb2ee1d6d1dc9f375107de4b70573ece8a4e13 (diff) | |
download | perl-5fcdf167f4386a3583bf0db9d98b989639295a45.tar.gz |
Implement sv_svset _nosteal variants by passing a flag into
sv_set_flags rather than messing with the SvTEMP() flag on either
side of the call.
p4raw-id: //depot/perl@23373
-rw-r--r-- | sv.c | 7 | ||||
-rw-r--r-- | sv.h | 6 |
2 files changed, 7 insertions, 6 deletions
@@ -4130,8 +4130,9 @@ function if the source SV needs to be reused. Does not handle 'set' magic. Loosely speaking, it performs a copy-by-value, obliterating any previous content of the destination. If the C<flags> parameter has the C<SV_GMAGIC> bit set, will C<mg_get> on -C<ssv> if appropriate, else not. C<sv_setsv> and C<sv_setsv_nomg> are -implemented in terms of this function. +C<ssv> if appropriate, else not. If the C<flags> parameter has the +C<NOSTEAL> bit set then the buffers of temps will not be stolen. <sv_setsv> +and C<sv_setsv_nomg> are implemented in terms of this function. You probably want to use one of the assortment of wrappers, such as C<SvSetSV>, C<SvSetSV_nosteal>, C<SvSetMagicSV> and @@ -4515,6 +4516,8 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags) !(isSwipe = (sflags & SVs_TEMP) && /* slated for free anyway? */ !(sflags & SVf_OOK) && /* and not involved in OOK hack? */ + (!(flags & SV_NOSTEAL)) && + /* and we're allowed to steal temps */ SvREFCNT(sstr) == 1 && /* and no other references to it? */ SvLEN(sstr) && /* and really is a string */ /* and won't be needed again, potentially */ @@ -1103,6 +1103,7 @@ Like C<sv_catsv> but doesn't process magic. #define SV_GMAGIC 2 #define SV_COW_DROP_PV 4 #define SV_UTF8_NO_ENCODING 8 +#define SV_NOSTEAL 16 /* We are about to replace the SV's current value. So if it's copy on write we need to normalise it. Use the SV_COW_DROP_PV flag hint to say that @@ -1242,10 +1243,7 @@ Returns a pointer to the character buffer. #define SvSetSV_nosteal_and(dst,src,finally) \ STMT_START { \ if ((dst) != (src)) { \ - U32 tMpF = SvFLAGS(src) & SVs_TEMP; \ - SvTEMP_off(src); \ - sv_setsv(dst, src); \ - SvFLAGS(src) |= tMpF; \ + sv_setsv_flags(dst, src, SV_GMAGIC | SV_NOSTEAL); \ finally; \ } \ } STMT_END |