summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHåvard Pettersen <3535158+havardpe@users.noreply.github.com>2022-05-20 10:06:39 +0200
committerGitHub <noreply@github.com>2022-05-20 10:06:39 +0200
commit2e1bf435671d233ac70635c1bc338da0153aec86 (patch)
treec177712d2e48b8429b08a6de6b02f4a1636a245e
parentbff1a34dd62df8033973a8d66815e5960675eda2 (diff)
parent505855381c648ee0bbc06cf9ec5c876b129057bb (diff)
Merge pull request #22677 from vespa-engine/balder/use-method-static-instead-of-global
Use method static instead of global to enable use in other static/glo…
-rw-r--r--vespalib/src/vespa/vespalib/util/alloc.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/vespalib/src/vespa/vespalib/util/alloc.cpp b/vespalib/src/vespa/vespalib/util/alloc.cpp
index c79db622901..d7e134cbb5a 100644
--- a/vespalib/src/vespa/vespalib/util/alloc.cpp
+++ b/vespalib/src/vespa/vespalib/util/alloc.cpp
@@ -234,8 +234,13 @@ createAutoAllocatorsWithDefault() {
return tmp;
}
+AutoAllocatorsMapWithDefault &
+availableAutoAllocators() {
+ static AutoAllocatorsMapWithDefault S_availableAutoAllocators = createAutoAllocatorsWithDefault();
+ return S_availableAutoAllocators;
+}
+
-AutoAllocatorsMapWithDefault _G_availableAutoAllocators = createAutoAllocatorsWithDefault();
alloc::HeapAllocator _G_heapAllocatorDefault;
alloc::AlignedHeapAllocator _G_512BalignedHeapAllocator(512);
alloc::AlignedHeapAllocator _G_1KalignedHeapAllocator(1_Ki);
@@ -268,12 +273,12 @@ MMapAllocator::getDefault() {
MemoryAllocator &
AutoAllocator::getDefault() {
- return *_G_availableAutoAllocators.second;
+ return *availableAutoAllocators().second;
}
MemoryAllocator &
AutoAllocator::getAllocator(size_t mmapLimit, size_t alignment) {
- return getAutoAllocator(_G_availableAutoAllocators.first, mmapLimit, alignment);
+ return getAutoAllocator(availableAutoAllocators().first, mmapLimit, alignment);
}
MemoryAllocator::PtrAndSize