diff options
author | Nicholas Clark <nick@ccl4.org> | 2005-06-20 15:21:59 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2005-06-20 15:21:59 +0000 |
commit | 7cfef17eab04537f006d60ddc6f37dc295472966 (patch) | |
tree | ea7fca1174f6b02ea5ca0dbcf456f85077a69150 /sv.c | |
parent | 53c1dcc098c6cc47963786f1928061d90b5d30e1 (diff) | |
download | perl-7cfef17eab04537f006d60ddc6f37dc295472966.tar.gz |
Replace the non-const initialiser block + loop with a series of calls
to a small static function.
c.f. "I will replace you with a small shell script..."
p4raw-id: //depot/perl@24914
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 81 |
1 files changed, 31 insertions, 50 deletions
@@ -509,6 +509,15 @@ Perl_sv_clean_all(pTHX) return cleaned; } +static void +S_free_arena(pTHX_ void **root) { + while (root) { + void **next = *(void **)root; + Safefree(root); + root = next; + } +} + /* =for apidoc sv_free_arenas @@ -518,49 +527,18 @@ heads and bodies within the arenas must already have been freed. =cut */ +#define free_arena(name) \ + STMT_START { \ + S_free_arena(aTHX_ (void**) PL_ ## name ## _arenaroot); \ + PL_ ## name ## _arenaroot = 0; \ + PL_ ## name ## _root = 0; \ + } STMT_END + void 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**) &PL_he_arenaroot, -#if defined(USE_ITHREADS) - (void**) &PL_pte_arenaroot, -#endif - (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**) &PL_he_root, -#if defined(USE_ITHREADS) - (void**) &PL_pte_root, -#endif - (void**) 0 - }; /* Free arenas here, but be careful about fake ones. (We assume contiguity of the fake ones with the corresponding real ones.) */ @@ -574,18 +552,21 @@ Perl_sv_free_arenas(pTHX) Safefree(sva); } - assert(sizeof(arenaroots) == sizeof(roots)); - - for (i=0; arenaroots[i]; i++) { - - arena = *arenaroots[i]; - for (; arena; arena = arenanext) { - arenanext = *(void **)arena; - Safefree(arena); - } - *arenaroots[i] = 0; - *roots[i] = 0; - } + free_arena(xnv); + free_arena(xpv); + free_arena(xpviv); + free_arena(xpvnv); + free_arena(xpvcv); + free_arena(xpvav); + free_arena(xpvhv); + free_arena(xpvmg); + free_arena(xpvgv); + free_arena(xpvlv); + free_arena(xpvbm); + free_arena(he); +#if defined(USE_ITHREADS) + free_arena(pte); +#endif if (PL_nice_chunk) Safefree(PL_nice_chunk); |