From: Nicholas Clark Date: Fri, 9 Dec 2005 19:18:32 +0000 (+0000) Subject: An alternative way of structuring ptr_table_clear so that the variables X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d5cefff9a50376f4dad17a00e206b5748a29f116;p=p5sagit%2Fp5-mst-13.2.git An alternative way of structuring ptr_table_clear so that the variables can be assigned to at declaration time. p4raw-id: //depot/perl@26313 --- diff --git a/sv.c b/sv.c index d4baffc..9ed37cb 100644 --- a/sv.c +++ b/sv.c @@ -9127,27 +9127,22 @@ Perl_ptr_table_split(pTHX_ PTR_TBL_t *tbl) void Perl_ptr_table_clear(pTHX_ PTR_TBL_t *tbl) { - register PTR_TBL_ENT_t **array; - UV riter = 0; + if (tbl && tbl->tbl_items) { + register PTR_TBL_ENT_t **array = tbl->tbl_ary; + UV riter = tbl->tbl_max; - if (!tbl || !tbl->tbl_items) { - return; - } - - array = tbl->tbl_ary; - riter = tbl->tbl_max; - - do { - PTR_TBL_ENT_t *entry = array[riter]; + do { + PTR_TBL_ENT_t *entry = array[riter]; - while (entry) { - PTR_TBL_ENT_t *oentry = entry; - entry = entry->next; - del_pte(oentry); - } - } while (riter--); + while (entry) { + PTR_TBL_ENT_t *oentry = entry; + entry = entry->next; + del_pte(oentry); + } + } while (riter--); - tbl->tbl_items = 0; + tbl->tbl_items = 0; + } } /* clear and free a ptr table */