From: Nicholas Clark Date: Wed, 22 Jun 2005 10:08:43 +0000 (+0000) Subject: Now that the global string table is using a single hunk of memory X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=804599610624faf0c46c8ed90e2d6d4956f5b897;p=p5sagit%2Fp5-mst-13.2.git Now that the global string table is using a single hunk of memory for both HE and HEK, we need to actually free things in perl_destruct p4raw-id: //depot/perl@24936 --- diff --git a/perl.c b/perl.c index 7f48fee..6a3b3f8 100644 --- a/perl.c +++ b/perl.c @@ -803,23 +803,23 @@ perl_destruct(pTHXx) { /* Yell and reset the HeVAL() slots that are still holding refcounts, * so that sv_free() won't fail on them. + * Now that the global string table is using a single hunk of memory + * for both HE and HEK, we either need to explicitly unshare it the + * correct way, or actually free things here. */ - I32 riter; - I32 max; - HE *hent; - HE **array; - - riter = 0; - max = HvMAX(PL_strtab); - array = HvARRAY(PL_strtab); - hent = array[0]; + I32 riter = 0; + const I32 max = HvMAX(PL_strtab); + HE **array = HvARRAY(PL_strtab); + HE *hent = array[0]; + for (;;) { if (hent && ckWARN_d(WARN_INTERNAL)) { + HE *next = HeNEXT(hent); Perl_warner(aTHX_ packWARN(WARN_INTERNAL), "Unbalanced string table refcount: (%d) for \"%s\"", HeVAL(hent) - Nullsv, HeKEY(hent)); - HeVAL(hent) = Nullsv; - hent = HeNEXT(hent); + Safefree(hent); + hent = next; } if (!hent) { if (++riter > max) @@ -827,6 +827,11 @@ perl_destruct(pTHXx) hent = array[riter]; } } + + Safefree(array); + HvARRAY(PL_strtab) = 0; + HvTOTALKEYS(PL_strtab) = 0; + HvFILL(PL_strtab) = 0; } SvREFCNT_dec(PL_strtab);