From: Dan Sugalski Date: Tue, 28 Jun 2005 16:01:59 +0000 (-0800) Subject: import Devel-Size 0.62 from CPAN X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-Size.git;a=commitdiff_plain;h=98ecbbc6c212eef2620e62ec70db99bd81160683 import Devel-Size 0.62 from CPAN git-cpan-module: Devel-Size git-cpan-version: 0.62 git-cpan-authorid: DSUGAL git-cpan-file: authors/id/D/DS/DSUGAL/Devel-Size-0.62.tar.gz --- diff --git a/Changes b/Changes index b8c9075..c2708e5 100755 --- a/Changes +++ b/Changes @@ -33,6 +33,12 @@ Revision history for Perl extension Devel::Size. - Applied documentation and sane warning patch from Nigel Sandever - Taught Devel::Size how to size up IO and globs properly -0.61 Mon Jun 17 16:19:00 2005 +0.61 Mon Jun 27 16:19:00 2005 - Added more checks for formats - Got CVs sizing right + +0.62 Tue Jun 28 11:59:00 2005 + - Took out // comments + - Added in copyright notice + - Some small amount of regex parsing + - Suppress multiple copies of each warning on each call \ No newline at end of file diff --git a/META.yml b/META.yml index 77a1f33..819a41e 100644 --- a/META.yml +++ b/META.yml @@ -1,7 +1,7 @@ # http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Devel-Size -version: 0.61 +version: 0.62 version_from: Size.pm installdirs: site requires: diff --git a/Size.pm b/Size.pm index ec248cb..5918034 100755 --- a/Size.pm +++ b/Size.pm @@ -24,7 +24,7 @@ require DynaLoader; @EXPORT = qw( ); -$VERSION = '0.61'; +$VERSION = '0.62'; bootstrap Devel::Size $VERSION; @@ -245,6 +245,15 @@ allocation alignments, or C library overhead. Dan Sugalski dan@sidhe.org +Small portion taken from the B module as shipped with perl 5.6.2. + +=head1 COPYRIGHT + +Copyright (C) 2005 Dan Sugalski. + +This module is free software; you can redistribute it and/or modify it +under the same terms as Perl itself. + =head1 SEE ALSO perl(1). diff --git a/Size.xs b/Size.xs index a112d3e..bd1b20c 100755 --- a/Size.xs +++ b/Size.xs @@ -2,6 +2,10 @@ #include "perl.h" #include "XSUB.h" +static int regex_whine; +static int fm_whine; + + #define carp puts UV thing_size(SV *, HV *); typedef enum { @@ -190,6 +194,16 @@ IV magic_size(SV *thing, HV *tracking_hash) { UV regex_size(REGEXP *baseregex, HV *tracking_hash) { UV total_size = 0; + total_size += sizeof(REGEXP); + /* Note hte size of the paren offset thing */ + total_size += sizeof(I32) * baseregex->nparens * 2; + total_size += strlen(baseregex->precomp); + + if (go_yell && !regex_whine) { + carp("Devel::Size: Calculated sizes for compiled regexes are incomple, and probably always will be"); + regex_whine = 1; + } + return total_size; } @@ -257,9 +271,17 @@ UV op_size(OP *baseop, HV *tracking_hash) { if (check_new(tracking_hash, cPMOPx(baseop)->op_pmnext)) { total_size += op_size((OP *)cPMOPx(baseop)->op_pmnext, tracking_hash); } - // if (check_new(tracking_hash, cPMOPx(baseop)->op_pmregexp)) { - // total_size += regex_size(cPMOPx(baseop)->op_pmregexp, tracking_hash); - //} + /* This is defined away in perl 5.8.x, but it is in there for + 5.6.x */ +#ifdef PM_GETRE + if (check_new(tracking_hash, PM_GETRE((cPMOPx(baseop))))) { + total_size += regex_size(PM_GETRE(cPMOPx(baseop)), tracking_hash); + } +#else + if (check_new(tracking_hash, cPMOPx(baseop)->op_pmregexp)) { + total_size += regex_size(cPMOPx(baseop)->op_pmregexp, tracking_hash); + } +#endif break; case OPc_SVOP: total_size += sizeof(struct pmop); @@ -288,9 +310,12 @@ UV op_size(OP *baseop, HV *tracking_hash) { if (check_new(tracking_hash, cLOOPx(baseop)->op_nextop)) { total_size += op_size(cLOOPx(baseop)->op_nextop, tracking_hash); } -// if (check_new(tracking_hash, cLOOPx(baseop)->op_lastop)) { -// total_size += op_size(cLOOPx(baseop)->op_lastop, tracking_hash); -// } + /* Not working for some reason, but the code's here for later + fixing + if (check_new(tracking_hash, cLOOPx(baseop)->op_lastop)) { + total_size += op_size(cLOOPx(baseop)->op_lastop, tracking_hash); + } + */ case OPc_COP: { COP *basecop; @@ -507,8 +532,9 @@ UV thing_size(SV *orig_thing, HV *tracking_hash) { total_size += thing_size((SV *)CvOUTSIDE(thing), tracking_hash); } - if (go_yell) { + if (go_yell && !fm_whine) { carp("Devel::Size: Calculated sizes for FMs are incomplete"); + fm_whine = 1; } break; case SVt_PVIO: @@ -571,6 +597,8 @@ CODE: /* Check warning status */ go_yell = 0; + regex_whine = 0; + fm_whine = 0; if (NULL != (warn_flag = perl_get_sv("Devel::Size::warn", FALSE))) { go_yell = SvIV(warn_flag); @@ -610,6 +638,8 @@ CODE: /* Check warning status */ go_yell = 0; + regex_whine = 0; + fm_whine = 0; if (NULL != (warn_flag = perl_get_sv("Devel::Size::warn", FALSE))) { go_yell = SvIV(warn_flag);