summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-11-18 17:37:39 +0000
committerNicholas Clark <nick@ccl4.org>2005-11-18 17:37:39 +0000
commit130ceb687ea0388cc3ad1ff82ffcdd90bb027d38 (patch)
tree77c0b5a375c08d41e9ce2d8829ddc9b802004cb6
parent483735aef73027b1cb70b07e3104cf48a86b40f1 (diff)
downloadperl-130ceb687ea0388cc3ad1ff82ffcdd90bb027d38.tar.gz
Merge the last remaining case duplication in sv_upgrade
p4raw-id: //depot/perl@26164
-rw-r--r--sv.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/sv.c b/sv.c
index 6a342cb44c..3498cbf075 100644
--- a/sv.c
+++ b/sv.c
@@ -1384,7 +1384,8 @@ static const struct body_details bodies_by_type[] = {
/* no arena for you! */
-#define new_NOARENA(s) my_safecalloc(s)
+#define new_NOARENA(details) \
+ my_safecalloc((details)->size - (details)->offset)
#define new_XPVFM() my_safemalloc(sizeof(XPVFM))
#define del_XPVFM(p) my_safefree(p)
@@ -1564,16 +1565,14 @@ Perl_sv_upgrade(pTHX_ register SV *sv, U32 new_type)
}
break;
- case SVt_PVIO:
- case SVt_PVFM:
- new_body = new_NOARENA(new_type_details->size);
- goto post_zero;
case SVt_PVIV:
/* XXX Is this still needed? Was it ever needed? Surely as there is
no route from NV to PVIV, NOK can never be true */
assert(!SvNOKp(sv));
assert(!SvNOK(sv));
+ case SVt_PVIO:
+ case SVt_PVFM:
case SVt_PVBM:
case SVt_PVGV:
case SVt_PVCV:
@@ -1582,19 +1581,19 @@ Perl_sv_upgrade(pTHX_ register SV *sv, U32 new_type)
case SVt_PVNV:
case SVt_PV:
+ assert(new_type_details->size);
#ifndef PURIFY
- /* This points to the start of the allocated area. */
- new_body_inline(new_body, bodies_by_type[new_type].size, new_type);
- Zero(new_body, bodies_by_type[new_type].size, char);
+ if(new_type_details->arena) {
+ /* This points to the start of the allocated area. */
+ new_body_inline(new_body, new_type_details->size, new_type);
+ Zero(new_body, new_type_details->size, char);
+ new_body = ((char *)new_body) + new_type_details->offset;
+ } else {
+ new_body = new_NOARENA(new_type_details);
+ }
#else
/* We always allocated the full length item with PURIFY */
- new_body = my_safemalloc(bodies_by_type[new_type].size - bodies_by_type[new_type].offset);
- Zero(new_body, bodies_by_type[new_type].size - bodies_by_type[new_type].offset, char);
-
-#endif
- post_zero:
-#ifndef PURIFY
- new_body = ((char *)new_body) + bodies_by_type[new_type].offset;
+ new_body = new_NOARENA(new_type_details);
#endif
SvANY(sv) = new_body;