From: Dan Sugalski Date: Thu, 20 Mar 2003 18:15:45 +0000 (-0800) Subject: import Devel-Size 0.57 from CPAN X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ebb2c5b9e5a54f96dc1b0b1543b3bb1dec777b84;p=p5sagit%2FDevel-Size.git import Devel-Size 0.57 from CPAN git-cpan-module: Devel-Size git-cpan-version: 0.57 git-cpan-authorid: DSUGAL git-cpan-file: authors/id/D/DS/DSUGAL/Devel-Size-0.57.tar.gz --- diff --git a/Size.pm b/Size.pm index f1a3866..3ddade8 100644 --- a/Size.pm +++ b/Size.pm @@ -24,10 +24,12 @@ require DynaLoader; @EXPORT = qw( ); -$VERSION = '0.56'; +$VERSION = '0.57'; bootstrap Devel::Size $VERSION; +our $warn = 1; + # Preloaded methods go here. 1; diff --git a/Size.xs b/Size.xs index 348346d..a2980d6 100644 --- a/Size.xs +++ b/Size.xs @@ -8,6 +8,8 @@ #define NV double #endif +static int go_yell = 1; + /* Checks to see if thing is in the hash. Returns true or false, and notes thing in the hash. @@ -165,7 +167,9 @@ UV thing_size(SV *orig_thing, HV *tracking_hash) { case SVt_PVCV: total_size += sizeof(XPVCV); total_size += magic_size(thing, tracking_hash); - carp("CV isn't complete"); + if (go_yell) { + carp("CV isn't complete"); + } break; case SVt_PVGV: total_size += magic_size(thing, tracking_hash); @@ -186,11 +190,15 @@ UV thing_size(SV *orig_thing, HV *tracking_hash) { break; case SVt_PVFM: total_size += sizeof(XPVFM); - carp("FM isn't complete"); + if (go_yell) { + carp("FM isn't complete"); + } break; case SVt_PVIO: total_size += sizeof(XPVIO); - carp("IO isn't complete"); + if (go_yell) { + carp("IO isn't complete"); + } break; default: croak("Unknown variable type"); @@ -210,6 +218,15 @@ CODE: SV *thing = orig_thing; /* Hash to track our seen pointers */ HV *tracking_hash = newHV(); + SV *warn_flag; + + /* Check warning status */ + go_yell = 0; + + if (NULL != (warn_flag = get_sv("Devel::Size::warn", FALSE))) { + go_yell = SvIV(warn_flag); + } + /* If they passed us a reference then dereference it. This is the only way we can check the sizes of arrays and hashes */ @@ -235,12 +252,21 @@ CODE: HV *tracking_hash = newHV(); AV *pending_array = newAV(); IV size = 0; + SV *warn_flag; IV count = 0; /* Size starts at zero */ RETVAL = 0; + /* Check warning status */ + go_yell = 0; + + if (NULL != (warn_flag = get_sv("Devel::Size::warn", FALSE))) { + go_yell = SvIV(warn_flag); + } + + /* If they passed us a reference then dereference it. This is the only way we can check the sizes of arrays and hashes */ if (SvOK(thing) && SvROK(thing)) {