diff options
author | Nicholas Clark <nick@ccl4.org> | 2005-04-28 11:22:15 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2005-04-28 11:22:15 +0000 |
commit | 8bd4d4c5ee440ccae167e2a7f5bf6f74ff02916b (patch) | |
tree | a0c18027ed2df90e52cd3274c69bcff795b71d6f /sv.h | |
parent | 9dcb96024af7087d05f03617e991e04fef9ff716 (diff) | |
download | perl-8bd4d4c5ee440ccae167e2a7f5bf6f74ff02916b.tar.gz |
Add a new macro SvPV_free() which undoes OOK and free()s the PVX(),
becase there's a lot of code around that calls SvOOK_off(), memmov()s
the buffer, then promptly free()s it. So avoid the needless memmov().
p4raw-id: //depot/perl@24348
Diffstat (limited to 'sv.h')
-rw-r--r-- | sv.h | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -842,6 +842,18 @@ in gv.h: */ SvPV_renew(sv, _lEnGtH); \ } STMT_END +#define SvPV_free(sv) \ + STMT_START { assert(SvTYPE(sv) >= SVt_PV); \ + if (SvLEN(sv)) { \ + if(SvOOK(sv)) { \ + Safefree(SvPVX(sv) - SvIVX(sv)); \ + SvFLAGS(sv) &= ~SVf_OOK; \ + } else { \ + Safefree(SvPVX(sv)); \ + } \ + } \ + } STMT_END + #define BmRARE(sv) ((XPVBM*) SvANY(sv))->xbm_rare #define BmUSEFUL(sv) ((XPVBM*) SvANY(sv))->xbm_useful #define BmPREVIOUS(sv) ((XPVBM*) SvANY(sv))->xbm_previous |