X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=hv.c;h=1f9cd296b61968b730522b81af5623bc33b075e8;hb=af5683d1a11b86657bb9d3800d54c4d65ca7b5a0;hp=bec2ddb13da711b53746b7ddbacff43676b53091;hpb=5e258f8c4f5a59546ce9582992331280e7f0c2e3;p=p5sagit%2Fp5-mst-13.2.git diff --git a/hv.c b/hv.c index bec2ddb..1f9cd29 100644 --- a/hv.c +++ b/hv.c @@ -44,11 +44,9 @@ S_more_he(pTHX) HE* heend; he = (HE*) Perl_get_arena(aTHX_ PERL_ARENA_SIZE); - HeNEXT(he) = (HE*) PL_body_arenas; - PL_body_arenas = he; heend = &he[PERL_ARENA_SIZE / sizeof(HE) - 1]; - PL_body_roots[HE_SVSLOT] = ++he; + PL_body_roots[HE_SVSLOT] = he; while (he < heend) { HeNEXT(he) = (HE*)(he + 1); he++; @@ -93,7 +91,7 @@ S_new_he(pTHX) #endif STATIC HEK * -S_save_hek_flags(pTHX_ const char *str, I32 len, U32 hash, int flags) +S_save_hek_flags(const char *str, I32 len, U32 hash, int flags) { const int flags_masked = flags & HVhek_MASK; char *k; @@ -126,7 +124,7 @@ Perl_free_tied_hv_pool(pTHX) he = HeNEXT(he); del_HE(ohe); } - PL_hv_fetch_ent_mh = Nullhe; + PL_hv_fetch_ent_mh = NULL; } #if defined(USE_ITHREADS) @@ -156,7 +154,7 @@ Perl_he_dup(pTHX_ const HE *e, bool shared, CLONE_PARAMS* param) HE *ret; if (!e) - return Nullhe; + return NULL; /* look for it in the table first */ ret = (HE*)ptr_table_fetch(PL_ptr_table, e); if (ret) @@ -475,7 +473,7 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, Newx(k, HEK_BASESIZE + sizeof(SV*), char); HeKEY_hek(entry) = (HEK*)k; } - HeNEXT(entry) = Nullhe; + HeNEXT(entry) = NULL; HeSVKEY_set(entry, keysv); HeVAL(entry) = sv; sv_upgrade(sv, SVt_PVLV); @@ -587,7 +585,7 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, if (!HvARRAY(hv) && !needs_store) { if (flags & HVhek_FREEKEY) Safefree(key); - return Nullhe; + return NULL; } #ifdef ENV_IS_CASELESS else if (mg_find((SV*)hv, PERL_MAGIC_env)) { @@ -670,7 +668,7 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, masked_flags = (flags & HVhek_MASK); #ifdef DYNAMIC_ENV_FETCH - if (!HvARRAY(hv)) entry = Null(HE*); + if (!HvARRAY(hv)) entry = NULL; else #endif { @@ -859,7 +857,7 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, } STATIC void -S_hv_magic_check(pTHX_ HV *hv, bool *needs_copy, bool *needs_store) +S_hv_magic_check(HV *hv, bool *needs_copy, bool *needs_store) { const MAGIC *mg = SvMAGIC(hv); *needs_copy = FALSE; @@ -1720,7 +1718,7 @@ S_hfreeentries(pTHX_ HV *hv) hv_free_ent(hv, entry); } iter->xhv_riter = -1; /* HvRITER(hv) = -1 */ - iter->xhv_eiter = Null(HE*); /* HvEITER(hv) = Null(HE*) */ + iter->xhv_eiter = NULL; /* HvEITER(hv) = NULL */ /* There are now no allocated pointers in the aux structure. */ @@ -1822,7 +1820,7 @@ Perl_hv_undef(pTHX_ HV *hv) } static struct xpvhv_aux* -S_hv_auxinit(pTHX_ HV *hv) { +S_hv_auxinit(HV *hv) { struct xpvhv_aux *iter; char *array; @@ -1840,7 +1838,7 @@ S_hv_auxinit(pTHX_ HV *hv) { iter = HvAUX(hv); iter->xhv_riter = -1; /* HvRITER(hv) = -1 */ - iter->xhv_eiter = Null(HE*); /* HvEITER(hv) = Null(HE*) */ + iter->xhv_eiter = NULL; /* HvEITER(hv) = NULL */ iter->xhv_name = 0; iter->xhv_backreferences = 0; return iter; @@ -1875,7 +1873,7 @@ Perl_hv_iterinit(pTHX_ HV *hv) hv_free_ent(hv, entry); } iter->xhv_riter = -1; /* HvRITER(hv) = -1 */ - iter->xhv_eiter = Null(HE*); /* HvEITER(hv) = Null(HE*) */ + iter->xhv_eiter = NULL; /* HvEITER(hv) = NULL */ } else { hv_auxinit(hv); } @@ -1945,7 +1943,7 @@ Perl_hv_eiter_set(pTHX_ HV *hv, HE *eiter) { } void -Perl_hv_name_set(pTHX_ HV *hv, const char *name, I32 len, int flags) +Perl_hv_name_set(pTHX_ HV *hv, const char *name, U32 len, U32 flags) { dVAR; struct xpvhv_aux *iter; @@ -1953,6 +1951,9 @@ Perl_hv_name_set(pTHX_ HV *hv, const char *name, I32 len, int flags) PERL_UNUSED_ARG(flags); + if (len > I32_MAX) + Perl_croak(aTHX_ "panic: hv name too long (%"UVuf")", (UV) len); + if (SvOOK(hv)) { iter = HvAUX(hv); if (iter->xhv_name) { @@ -1971,6 +1972,7 @@ Perl_hv_name_set(pTHX_ HV *hv, const char *name, I32 len, int flags) AV ** Perl_hv_backreferences_p(pTHX_ HV *hv) { struct xpvhv_aux * const iter = SvOOK(hv) ? HvAUX(hv) : hv_auxinit(hv); + PERL_UNUSED_CONTEXT; return &(iter->xhv_backreferences); } @@ -2063,15 +2065,15 @@ Perl_hv_iternext_flags(pTHX_ HV *hv, I32 flags) magic_nextpack((SV*) hv,mg,key); if (SvOK(key)) { /* force key to stay around until next time */ - HeSVKEY_set(entry, SvREFCNT_inc(key)); + HeSVKEY_set(entry, SvREFCNT_inc_simple_NN(key)); return entry; /* beware, hent_val is not set */ } if (HeVAL(entry)) SvREFCNT_dec(HeVAL(entry)); Safefree(HeKEY_hek(entry)); del_HE(entry); - iter->xhv_eiter = Null(HE*); /* HvEITER(hv) = Null(HE*) */ - return Null(HE*); + iter->xhv_eiter = NULL; /* HvEITER(hv) = NULL */ + return NULL; } #ifdef DYNAMIC_ENV_FETCH /* set up %ENV for iteration */ if (!entry && SvRMAGICAL((SV*)hv) && mg_find((SV*)hv, PERL_MAGIC_env)) { @@ -2543,7 +2545,7 @@ Perl_hv_assert(pTHX_ HV *hv) } /* sanity check the keys */ if (HeSVKEY(entry)) { - /* Don't know what to check on SV keys. */ + /*EMPTY*/ /* Don't know what to check on SV keys. */ } else if (HeKUTF8(entry)) { withflags++; if (HeKWASUTF8(entry)) {