diff options
author | Håvard Pettersen <3535158+havardpe@users.noreply.github.com> | 2022-05-20 10:06:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-20 10:06:39 +0200 |
commit | 2e1bf435671d233ac70635c1bc338da0153aec86 (patch) | |
tree | c177712d2e48b8429b08a6de6b02f4a1636a245e | |
parent | bff1a34dd62df8033973a8d66815e5960675eda2 (diff) | |
parent | 505855381c648ee0bbc06cf9ec5c876b129057bb (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.cpp | 11 |
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 |