From: Tim Bunce Date: Tue, 2 Oct 2012 19:54:14 +0000 (+0100) Subject: Only set SIZEME for -d mode. Fix assertion when SIZEME env var not set. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=01f5c6f5be2f7f0c6955daaa8fa78f77359a4720;p=p5sagit%2FDevel-Size.git Only set SIZEME for -d mode. Fix assertion when SIZEME env var not set. --- diff --git a/SizeMe.xs b/SizeMe.xs index 6914a7f..ac296f1 100644 --- a/SizeMe.xs +++ b/SizeMe.xs @@ -187,7 +187,7 @@ struct state { #define ADD_LINK_ATTR(st, attr_type, attr_name, attr_value) \ STMT_START { \ - assert(NP->seqn); \ + if (st->add_attr_cb) assert(NP->seqn); \ _ADD_ATTR_NP(st, attr_type, attr_name, attr_value, NP); \ } STMT_END; @@ -1108,7 +1108,7 @@ sv_size(pTHX_ struct state *const st, pPATH, const SV * const orig_thing, type = SvTYPE(thing); if (type > SVt_LAST) { warn("Devel::Size: Unknown variable type: %d encountered\n", type); - return 1; + return 0; } NPathPushNode(thing, NPtype_SV); ADD_SIZE(st, "sv_head", sizeof(SV)); diff --git a/lib/Devel/SizeMe.pm b/lib/Devel/SizeMe.pm index 64b34b1..89a273e 100644 --- a/lib/Devel/SizeMe.pm +++ b/lib/Devel/SizeMe.pm @@ -13,6 +13,11 @@ BEGIN { | 0x200 # Provide informative names to anonymous subroutines; ; $do_size_at_end = 1; + + if (not defined $ENV{SIZEME}) { + $ENV{SIZEME} = "| sizeme_store.pl --db=sizeme.db"; + warn qq{SIZEME env var not set, defaulting to "$ENV{SIZEME}"\n}; + } } } @@ -32,11 +37,6 @@ $VERSION = '0.02'; $warn = 1; $dangle = 0; ## Set true to enable warnings about dangling pointers -if (not defined $ENV{SIZEME}) { - $ENV{SIZEME} = "| sizeme_store.pl --db=sizeme.db"; - warn qq{SIZEME env var not set, defaulting to "$ENV{SIZEME}"\n}; -} - XSLoader::load( __PACKAGE__); END {