This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use the C_ARRAY_LENGTH.
authorJarkko Hietaniemi <jhi@iki.fi>
Mon, 19 May 2014 10:52:24 +0000 (06:52 -0400)
committerSteffen Mueller <smueller@cpan.org>
Wed, 28 May 2014 13:20:52 +0000 (15:20 +0200)
commitc3caa5c3bdbd0ad0bc7ce5e7cd1a8eb5b7ca6a69
tree6dc141509d7e032a24af49a9ad0ba9892c7b893c
parent40b5a549d4793cde8b4d93ccdd03c16e039440c9
Use the C_ARRAY_LENGTH.

Use the C_ARRAY_LENGTH instead of sizeof(c_array)/sizeof(c_array[0])
or sizeof(c_array)/sizeof(type_of_element_in_c_array), and C_ARRAY_END
for c_array + C_ARRAY_LENGTH(c_array).

While doing this found potential off-by-one error in sv.c:Perl_sv_magic:
how > C_ARRAY_LENGTH(PL_magic_data)
should probably have been
how >= C_ARRAY_LENGTH(PL_magic_data)
No tests fail, but this seems to be more of an internal sanity check.
dump.c
handy.h
patchlevel.h
perl.c
sv.c
universal.c
util.c