X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=Size.xs;h=43b45cee30da7b1777287f11a45333927e21119f;hb=fea63ffab1b34bbefc1f75a7beee2c5bdc96d67e;hp=e92dbe61468e1d2c99d5a81cf316368d787aec33;hpb=e96acca968cf23f1c8e3aea35b251dedbc925a5b;p=p5sagit%2FDevel-Size.git diff --git a/Size.xs b/Size.xs index e92dbe6..43b45ce 100644 --- a/Size.xs +++ b/Size.xs @@ -165,11 +165,25 @@ UV thing_size(SV *orig_thing, HV *tracking_hash) { break; case SVt_PVCV: total_size += sizeof(XPVCV); + total_size += magic_size(thing, tracking_hash); carp("CV isn't complete"); break; case SVt_PVGV: + total_size += magic_size(thing, tracking_hash); total_size += sizeof(XPVGV); - carp("GC isn't complete"); + total_size += GvNAMELEN(thing); + /* Is there a file? */ + if (GvFILE(thing)) { + if (check_new(tracking_hash, GvFILE(thing))) { + total_size += strlen(GvFILE(thing)); + } + } + /* Is there something hanging off the glob? */ + if (GvGP(thing)) { + if (check_new(tracking_hash, GvGP(thing))) { + total_size += sizeof(GP); + } + } break; case SVt_PVFM: total_size += sizeof(XPVFM); @@ -185,9 +199,10 @@ UV thing_size(SV *orig_thing, HV *tracking_hash) { return total_size; } - MODULE = Devel::Size PACKAGE = Devel::Size +PROTOTYPES: DISABLE + IV size(orig_thing) SV *orig_thing @@ -273,14 +288,31 @@ CODE: case SVt_PVHV: /* Is there anything in here? */ if (hv_iterinit((HV *)thing)) { - SV *temp_thing; - while (&PL_sv_undef != - (temp_thing = hv_iternextsv((HV *)thing, NULL, NULL))) { - av_push(pending_array, temp_thing); + HE *temp_he; + while (temp_he = hv_iternext((HV *)thing)) { + av_push(pending_array, hv_iterval((HV *)thing, temp_he)); } } break; + case SVt_PVGV: + /* Run through all the pieces and push the ones with bits */ + if (GvSV(thing)) { + av_push(pending_array, (SV *)GvSV(thing)); + } + if (GvFORM(thing)) { + av_push(pending_array, (SV *)GvFORM(thing)); + } + if (GvAV(thing)) { + av_push(pending_array, (SV *)GvAV(thing)); + } + if (GvHV(thing)) { + av_push(pending_array, (SV *)GvHV(thing)); + } + if (GvCV(thing)) { + av_push(pending_array, (SV *)GvCV(thing)); + } + break; default: break; }