summaryrefslogtreecommitdiff
path: root/sv.h
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-04-18 21:58:22 +0000
committerNicholas Clark <nick@ccl4.org>2005-04-18 21:58:22 +0000
commit1da4ca5ff65374ad6965719e5eb33e3027a745a7 (patch)
tree378c39cf08d231c303fffa124644ea3300e1f46a /sv.h
parentb7e9a5c2d751f7ed3b8a703e57ac933ded5b16ce (diff)
downloadperl-1da4ca5ff65374ad6965719e5eb33e3027a745a7.tar.gz
SvPV_renew also calls SvLEN_set
Add SvPV_shrink_to_cur(sv) to call SvPV_renew with SvCUR(sv)+1. For Ponie this can be a single call into the PMC p4raw-id: //depot/perl@24245
Diffstat (limited to 'sv.h')
-rw-r--r--sv.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/sv.h b/sv.h
index 511b547c75..b90d209c5f 100644
--- a/sv.h
+++ b/sv.h
@@ -794,8 +794,16 @@ in gv.h: */
(SvCUR(sv) = (val) - SvPVX(sv)); } STMT_END
#define SvPV_renew(sv,n) \
- (SvPV_set((sv), (MEM_WRAP_CHECK_(n,char) \
- (char*)saferealloc((Malloc_t)SvPVX(sv),(MEM_SIZE)((n))))))
+ STMT_START { SvLEN_set(sv, n); \
+ SvPV_set((sv), (MEM_WRAP_CHECK_(n,char) \
+ (char*)saferealloc((Malloc_t)SvPVX(sv), \
+ (MEM_SIZE)((n))))); \
+ } STMT_END
+
+#define SvPV_shrink_to_cur(sv) STMT_START { \
+ const STRLEN _lEnGtH = SvCUR(sv) + 1; \
+ SvPV_renew(sv, _lEnGtH); \
+ } STMT_END
#define BmRARE(sv) ((XPVBM*) SvANY(sv))->xbm_rare
#define BmUSEFUL(sv) ((XPVBM*) SvANY(sv))->xbm_useful