From: Jim Cromie Date: Sat, 18 Jun 2005 00:47:36 +0000 (-0600) Subject: squeeze repetition out of Perl_sv_free_arenas X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8b4f5e176a26235e99161210aebb1bc0073474cd;p=p5sagit%2Fp5-mst-13.2.git squeeze repetition out of Perl_sv_free_arenas Message-ID: <42B3C388.2090902@divsol.com> Date: Sat, 18 Jun 2005 00:47:36 -0600 p4raw-id: //depot/perl@24894 --- diff --git a/sv.c b/sv.c index 65e04c5..174f893 100644 --- a/sv.c +++ b/sv.c @@ -524,6 +524,35 @@ Perl_sv_free_arenas(pTHX) SV* sva; SV* svanext; void *arena, *arenanext; + int i; + void **arenaroots[] = { + (void**) &PL_xnv_arenaroot, + (void**) &PL_xpv_arenaroot, + (void**) &PL_xpviv_arenaroot, + (void**) &PL_xpvnv_arenaroot, + (void**) &PL_xpvcv_arenaroot, + (void**) &PL_xpvav_arenaroot, + (void**) &PL_xpvhv_arenaroot, + (void**) &PL_xpvmg_arenaroot, + (void**) &PL_xpvgv_arenaroot, + (void**) &PL_xpvlv_arenaroot, + (void**) &PL_xpvbm_arenaroot, + (void**) 0 + }; + void **roots[] = { + (void**) &PL_xnv_root, + (void**) &PL_xpv_root, + (void**) &PL_xpviv_root, + (void**) &PL_xpvnv_root, + (void**) &PL_xpvcv_root, + (void**) &PL_xpvav_root, + (void**) &PL_xpvhv_root, + (void**) &PL_xpvmg_root, + (void**) &PL_xpvgv_root, + (void**) &PL_xpvlv_root, + (void**) &PL_xpvbm_root, + (void**) 0 + }; /* Free arenas here, but be careful about fake ones. (We assume contiguity of the fake ones with the corresponding real ones.) */ @@ -536,83 +565,19 @@ Perl_sv_free_arenas(pTHX) if (!SvFAKE(sva)) Safefree(sva); } + + assert(sizeof(arenaroots) == sizeof(roots)); - for (arena = PL_xnv_arenaroot; arena; arena = arenanext) { - arenanext = *(void **)arena; - Safefree(arena); - } - PL_xnv_arenaroot = 0; - PL_xnv_root = 0; - - for (arena = PL_xpv_arenaroot; arena; arena = arenanext) { - arenanext = *(void **)arena; - Safefree(arena); - } - PL_xpv_arenaroot = 0; - PL_xpv_root = 0; - - for (arena = PL_xpviv_arenaroot; arena; arena = arenanext) { - arenanext = *(void **)arena; - Safefree(arena); - } - PL_xpviv_arenaroot = 0; - PL_xpviv_root = 0; - - for (arena = PL_xpvnv_arenaroot; arena; arena = arenanext) { - arenanext = *(void **)arena; - Safefree(arena); - } - PL_xpvnv_arenaroot = 0; - PL_xpvnv_root = 0; - - for (arena = PL_xpvcv_arenaroot; arena; arena = arenanext) { - arenanext = *(void **)arena; - Safefree(arena); - } - PL_xpvcv_arenaroot = 0; - PL_xpvcv_root = 0; - - for (arena = PL_xpvav_arenaroot; arena; arena = arenanext) { - arenanext = *(void **)arena; - Safefree(arena); - } - PL_xpvav_arenaroot = 0; - PL_xpvav_root = 0; - - for (arena = PL_xpvhv_arenaroot; arena; arena = arenanext) { - arenanext = *(void **)arena; - Safefree(arena); - } - PL_xpvhv_arenaroot = 0; - PL_xpvhv_root = 0; - - for (arena = PL_xpvmg_arenaroot; arena; arena = arenanext) { - arenanext = *(void **)arena; - Safefree(arena); - } - PL_xpvmg_arenaroot = 0; - PL_xpvmg_root = 0; - - for (arena = PL_xpvgv_arenaroot; arena; arena = arenanext) { - arenanext = *(void **)arena; - Safefree(arena); - } - PL_xpvgv_arenaroot = 0; - PL_xpvgv_root = 0; + for (i=0; arenaroots[i]; i++) { - for (arena = PL_xpvlv_arenaroot; arena; arena = arenanext) { - arenanext = *(void **)arena; - Safefree(arena); - } - PL_xpvlv_arenaroot = 0; - PL_xpvlv_root = 0; - - for (arena = PL_xpvbm_arenaroot; arena; arena = arenanext) { - arenanext = *(void **)arena; - Safefree(arena); + arena = *arenaroots[i]; + for (; arena; arena = arenanext) { + arenanext = *(void **)arena; + Safefree(arena); + } + *arenaroots[i] = 0; + *roots[i] = 0; } - PL_xpvbm_arenaroot = 0; - PL_xpvbm_root = 0; { HE *he;