From 7fd94f82a8b04954eb129f6576be6ebfa44d0588 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Mon, 2 May 2022 15:08:37 -0700 Subject: [PATCH] simpler public calling interface for computing footprint --- src/Val.h | 11 +++++++++++ src/zeek.bif | 6 ++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Val.h b/src/Val.h index d0075f7259..cda69e0331 100644 --- a/src/Val.h +++ b/src/Val.h @@ -127,6 +127,17 @@ public: * The number is not meant to be precise, but rather comparable: * larger footprint correlates with more memory consumption. * + * @return The total footprint. + */ + unsigned int Footprint() const + { + std::set analyzed_records; + return Footprint(&analyzed_records); + } + + /** + * Internal function for computing a Val's "footprint". + * * @param analyzed_records A pointer to a set used to track which * records have been analyzed to date, used to prevent infinite * recursion. The set should be empty (but not nil) on the first call. diff --git a/src/zeek.bif b/src/zeek.bif index 1af134f4b5..07bfdf6e94 100644 --- a/src/zeek.bif +++ b/src/zeek.bif @@ -2008,8 +2008,7 @@ function global_container_footprints%(%): var_sizes continue; auto id_name = zeek::make_intrusive(id->Name()); - std::set analyzed_records; - auto fp = zeek::val_mgr->Count(v->Footprint(&analyzed_records)); + auto fp = zeek::val_mgr->Count(v->Footprint()); sizes->Assign(std::move(id_name), std::move(fp)); } @@ -2025,8 +2024,7 @@ function global_container_footprints%(%): var_sizes ## .. zeek:see:: global_container_footprints function val_footprint%(v: any%): count %{ - std::set analyzed_records; - return zeek::val_mgr->Count(v->Footprint(&analyzed_records)); + return zeek::val_mgr->Count(v->Footprint()); %} ## Generates a table with information about all global identifiers. The table