From: Nicholas Clark Date: Thu, 14 Apr 2011 10:35:20 +0000 (+0100) Subject: No need to explicitly check AvARYLEN in 5.10 and later. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-Size.git;a=commitdiff_plain;h=795fc84c62c127116baa0def5dfb7e52a6e5221d;hp=0d46c0bd49534388814d9797c6a5c2d52f168796 No need to explicitly check AvARYLEN in 5.10 and later. In 5.10 the struct slot was eliminated, and contents are now stored in magic, which will already be found. Whilst there's no direct "harm" in looking again, as the "seen" tracker will skip the second discovery, it's wasteful, and now generates a compilation error, as AvARYLEN() expects a mutable pointer, whereas the variable thing is const void *. This also resolves CPAN RT #49437 - Devel::Size adds magic in Perl 5.10 --- diff --git a/CHANGES b/CHANGES index b75405f..2fc570f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ Revision history for Perl extension Devel::Size. +0.72_50 2011-04-14 nicholas + * Resolve CPAN #49437 (Devel::Size adds magic in Perl 5.10) + 0.72 2008-10-14 BrowserUk 70 tests * Added bit-vector pointer tracking mechanism. - new fatal error (64-bit platforms only) diff --git a/Size.xs b/Size.xs index f1155a2..19725a0 100644 --- a/Size.xs +++ b/Size.xs @@ -548,12 +548,17 @@ UV thing_size(const SV * const orig_thing, TRACKING *tv) { if (AvALLOC(thing) != 0) { total_size += (sizeof(SV *) * (AvARRAY(thing) - AvALLOC(thing))); } - /* Is there something hanging off the arylen element? */ +#if (PERL_VERSION < 9) + /* Is there something hanging off the arylen element? + Post 5.9.something this is stored in magic, so will be found there, + and Perl_av_arylen_p() takes a non-const AV*, hence compilers rightly + complain about AvARYLEN() passing thing to it. */ if (AvARYLEN(thing)) { if (check_new(tv, AvARYLEN(thing))) { total_size += thing_size(AvARYLEN(thing), tv); } } +#endif total_size += magic_size(thing, tv); TAG;break; case SVt_PVHV: TAG;