This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_opslab_force_free() adjust loop test
authorDavid Mitchell <davem@iabyn.com>
Tue, 16 Jul 2019 15:30:42 +0000 (16:30 +0100)
committerDavid Mitchell <davem@iabyn.com>
Mon, 5 Aug 2019 10:32:05 +0000 (11:32 +0100)
Formerly, slots were allocated within a slab, but leaving the very top
word in the slab as a NULL pointer which appeared as a fake slot so that
a 'while (slot->opslot_next)' loop would stop. Since opslot_next has
been eradicated and the NULL is no longer allocated, the loop condition
for scanning all slots can be simplified slightly (with no change in
functionality).

op.c

diff --git a/op.c b/op.c
index c5eb387..5d0b1da 100644 (file)
--- a/op.c
+++ b/op.c
@@ -535,7 +535,7 @@ Perl_opslab_force_free(pTHX_ OPSLAB *slab)
                     ((I32**)&slab2->opslab_slots + slab2->opslab_free_space);
         OPSLOT *end  = (OPSLOT*)
                         ((I32**)slab2 + slab2->opslab_size);
-       for (; slot <= end -1;
+       for (; slot < end;
                 slot = (OPSLOT*) ((I32**)slot + slot->opslot_size) )
         {
            if (slot->opslot_op.op_type != OP_FREED