avoid unused variable warning for TCMallocImplementation space

This commit is contained in:
Aliaksey Kandratsenka 2023-12-31 23:16:00 -05:00
parent 1ba9f60579
commit fae6421668

View File

@ -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
}