X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=Size.xs;h=a2980d64ee499b0ca53a4ecad88d509366954364;hb=ebb2c5b9e5a54f96dc1b0b1543b3bb1dec777b84;hp=348346d59880c0a5f0a2b3ed500d9764cd92bbd3;hpb=966a1570c7ce7e07dfb937f4d5ae0ab35a029496;p=p5sagit%2FDevel-Size.git 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)) {