We only need to zero new bodies for upgrades. sv_dup doesn't need to
Nicholas Clark [Fri, 18 Nov 2005 21:25:23 +0000 (21:25 +0000)]
zero as it's copying over the same sized structure. So change
new_NOARENA to malloc(), and add new_NOARENAZ() to calloc()

p4raw-id: //depot/perl@26168

sv.c

diff --git a/sv.c b/sv.c
index e67c716..b6bd46c 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -1393,6 +1393,8 @@ static const struct body_details bodies_by_type[] = {
 /* no arena for you! */
 
 #define new_NOARENA(details) \
+       my_safemalloc((details)->size - (details)->offset)
+#define new_NOARENAZ(details) \
        my_safecalloc((details)->size - (details)->offset)
 
 #define new_XPVFM()    my_safemalloc(sizeof(XPVFM))
@@ -1597,11 +1599,11 @@ Perl_sv_upgrade(pTHX_ register SV *sv, U32 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);
+           new_body = new_NOARENAZ(new_type_details);
        }
 #else
        /* We always allocated the full length item with PURIFY */
-       new_body = new_NOARENA(new_type_details);
+       new_body = new_NOARENAZ(new_type_details);
 #endif
        SvANY(sv) = new_body;
 
@@ -10058,7 +10060,6 @@ Perl_sv_dup(pTHX_ SV *sstr, CLONE_PARAMS* param)
            const svtype sv_type = SvTYPE(sstr);
            const struct body_details *const sv_type_details
                = bodies_by_type + sv_type;
-           
 
            switch (sv_type) {
            default: