Fix final placement new in metric.cpp
This commit is contained in:
@@ -350,13 +350,15 @@ struct Metric {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static auto &get_gauge_families() {
|
static auto &get_gauge_families() {
|
||||||
using FamilyMap = std::map<
|
using FamilyMap =
|
||||||
std::string_view, Family<Gauge>::State *, std::less<std::string_view>,
|
std::map<std::string_view, ArenaAllocator::Ptr<Family<Gauge>::State>,
|
||||||
|
std::less<std::string_view>,
|
||||||
ArenaStlAllocator<
|
ArenaStlAllocator<
|
||||||
std::pair<const std::string_view, Family<Gauge>::State *>>>;
|
std::pair<const std::string_view,
|
||||||
|
ArenaAllocator::Ptr<Family<Gauge>::State>>>>;
|
||||||
static FamilyMap *gaugeFamilies = new FamilyMap(
|
static FamilyMap *gaugeFamilies = new FamilyMap(
|
||||||
ArenaStlAllocator<
|
ArenaStlAllocator<std::pair<const std::string_view,
|
||||||
std::pair<const std::string_view, Family<Gauge>::State *>>(
|
ArenaAllocator::Ptr<Family<Gauge>::State>>>(
|
||||||
&get_global_arena()));
|
&get_global_arena()));
|
||||||
return *gaugeFamilies;
|
return *gaugeFamilies;
|
||||||
}
|
}
|
||||||
@@ -901,9 +903,7 @@ Family<Gauge> create_gauge(std::string_view name, std::string_view help) {
|
|||||||
if (!familyPtr) {
|
if (!familyPtr) {
|
||||||
// NOTE: Family<T>::State instances are never destroyed - this is fine
|
// NOTE: Family<T>::State instances are never destroyed - this is fine
|
||||||
// because the number of metric families is bounded by application design
|
// because the number of metric families is bounded by application design
|
||||||
familyPtr = new (global_arena.allocate_raw(sizeof(Family<Gauge>::State),
|
familyPtr = global_arena.construct<Family<Gauge>::State>(global_arena);
|
||||||
alignof(Family<Gauge>::State)))
|
|
||||||
Family<Gauge>::State(global_arena);
|
|
||||||
familyPtr->name = name_view;
|
familyPtr->name = name_view;
|
||||||
familyPtr->help = arena_copy_string(help, global_arena);
|
familyPtr->help = arena_copy_string(help, global_arena);
|
||||||
} else {
|
} else {
|
||||||
@@ -912,7 +912,7 @@ Family<Gauge> create_gauge(std::string_view name, std::string_view help) {
|
|||||||
"metric family already registered with different help text", name);
|
"metric family already registered with different help text", name);
|
||||||
}
|
}
|
||||||
Family<Gauge> family;
|
Family<Gauge> family;
|
||||||
family.p = familyPtr;
|
family.p = familyPtr.get();
|
||||||
return family;
|
return family;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user