From fae6421668dd640afc4c7fb08134e53c240b4235 Mon Sep 17 00:00:00 2001 From: Aliaksey Kandratsenka Date: Sun, 31 Dec 2023 23:16:00 -0500 Subject: [PATCH] avoid unused variable warning for TCMallocImplementation space --- src/tcmalloc.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tcmalloc.cc b/src/tcmalloc.cc index 39e515a..dcb9460 100644 --- a/src/tcmalloc.cc +++ b/src/tcmalloc.cc @@ -1097,11 +1097,6 @@ size_t TCMallocImplementation::GetEstimatedAllocatedSize(size_t size) { return tc_nallocx(size, 0); } -static union { - char chars[sizeof(TCMallocImplementation)]; - void *ptr; -} tcmallocimplementation_implementation_space; - // The constructor allocates an object to ensure that initialization // runs before main(), and therefore we do not have a chance to become // multi-threaded before initialization. We also create the TSD key @@ -1129,7 +1124,12 @@ TCMallocGuard::TCMallocGuard() { if (RunningOnValgrind()) { // Let Valgrind uses its own malloc (so don't register our extension). } else { - MallocExtension::Register(new (tcmallocimplementation_implementation_space.chars) TCMallocImplementation()); + static union { + char chars[sizeof(TCMallocImplementation)]; + void *ptr; + } tcmallocimplementation_space; + + MallocExtension::Register(new (tcmallocimplementation_space.chars) TCMallocImplementation()); } #endif }