summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-12-09 19:18:32 +0000
committerNicholas Clark <nick@ccl4.org>2005-12-09 19:18:32 +0000
commitd5cefff9a50376f4dad17a00e206b5748a29f116 (patch)
treefd50e9405837d7ed63fb9717882b7b3a77bcaac2 /sv.c
parentab1e7f954de0531c104e9628076d0ac3e768f895 (diff)
downloadperl-d5cefff9a50376f4dad17a00e206b5748a29f116.tar.gz
An alternative way of structuring ptr_table_clear so that the variables
can be assigned to at declaration time. p4raw-id: //depot/perl@26313
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/sv.c b/sv.c
index d4baffc0c4..9ed37cb03b 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 */