This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
As PERL_HV_ARRAY_ALLOC_BYTES is bytes, not items, the type should be
authorNicholas Clark <nick@ccl4.org>
Wed, 1 Jun 2005 15:08:02 +0000 (15:08 +0000)
committerNicholas Clark <nick@ccl4.org>
Wed, 1 Jun 2005 15:08:02 +0000 (15:08 +0000)
char rather than HE *. Bug was harmless, overallocating by a factor
of sizeof(HE *)

p4raw-id: //depot/perl@24661

hv.c

diff --git a/hv.c b/hv.c
index cfb3812..7df3977 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -603,10 +603,13 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
 #ifdef DYNAMIC_ENV_FETCH  /* if it's an %ENV lookup, we may get it on the fly */
                 || (SvRMAGICAL((SV*)hv) && mg_find((SV*)hv, PERL_MAGIC_env))
 #endif
 #ifdef DYNAMIC_ENV_FETCH  /* if it's an %ENV lookup, we may get it on the fly */
                 || (SvRMAGICAL((SV*)hv) && mg_find((SV*)hv, PERL_MAGIC_env))
 #endif
-                                                                 )
-           Newz(503, HvARRAY(hv),
+                                                                 ) {
+           char *array;
+           Newz(503, array,
                 PERL_HV_ARRAY_ALLOC_BYTES(xhv->xhv_max+1 /* HvMAX(hv)+1 */),
                 PERL_HV_ARRAY_ALLOC_BYTES(xhv->xhv_max+1 /* HvMAX(hv)+1 */),
-                HE*);
+                char);
+           HvARRAY(hv) = (HE**)array;
+       }
 #ifdef DYNAMIC_ENV_FETCH
        else if (action & HV_FETCH_ISEXISTS) {
            /* for an %ENV exists, if we do an insert it's by a recursive
 #ifdef DYNAMIC_ENV_FETCH
        else if (action & HV_FETCH_ISEXISTS) {
            /* for an %ENV exists, if we do an insert it's by a recursive
@@ -773,9 +776,11 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
        /* Not sure if we can get here.  I think the only case of oentry being
           NULL is for %ENV with dynamic env fetch.  But that should disappear
           with magic in the previous code.  */
        /* Not sure if we can get here.  I think the only case of oentry being
           NULL is for %ENV with dynamic env fetch.  But that should disappear
           with magic in the previous code.  */
-       Newz(503, HvARRAY(hv),
+       char *array;
+       Newz(503, array,
             PERL_HV_ARRAY_ALLOC_BYTES(xhv->xhv_max+1 /* HvMAX(hv)+1 */),
             PERL_HV_ARRAY_ALLOC_BYTES(xhv->xhv_max+1 /* HvMAX(hv)+1 */),
-            HE*);
+            char);
+       HvARRAY(hv) = (HE**)array;
     }
 
     oentry = &(HvARRAY(hv))[hash & (I32) xhv->xhv_max];
     }
 
     oentry = &(HvARRAY(hv))[hash & (I32) xhv->xhv_max];