diff --git a/src/metric.cpp b/src/metric.cpp index 4359095..a2dab1b 100644 --- a/src/metric.cpp +++ b/src/metric.cpp @@ -350,13 +350,15 @@ struct Metric { } static auto &get_gauge_families() { - using FamilyMap = std::map< - std::string_view, Family::State *, std::less, - ArenaStlAllocator< - std::pair::State *>>>; + using FamilyMap = + std::map::State>, + std::less, + ArenaStlAllocator< + std::pair::State>>>>; static FamilyMap *gaugeFamilies = new FamilyMap( - ArenaStlAllocator< - std::pair::State *>>( + ArenaStlAllocator::State>>>( &get_global_arena())); return *gaugeFamilies; } @@ -901,9 +903,7 @@ Family create_gauge(std::string_view name, std::string_view help) { if (!familyPtr) { // NOTE: Family::State instances are never destroyed - this is fine // because the number of metric families is bounded by application design - familyPtr = new (global_arena.allocate_raw(sizeof(Family::State), - alignof(Family::State))) - Family::State(global_arena); + familyPtr = global_arena.construct::State>(global_arena); familyPtr->name = name_view; familyPtr->help = arena_copy_string(help, global_arena); } else { @@ -912,7 +912,7 @@ Family create_gauge(std::string_view name, std::string_view help) { "metric family already registered with different help text", name); } Family family; - family.p = familyPtr; + family.p = familyPtr.get(); return family; }