Add free-function retire
[folly.git] / folly / experimental / JemallocNodumpAllocator.cpp
index 8d29dbc82109e2c87f00ccda5a781ff4cddda9a3..5824c11a8fc7372340ae9b8d0a494c36045cdd96 100644 (file)
@@ -17,8 +17,8 @@
 #include <folly/experimental/JemallocNodumpAllocator.h>
 
 #include <folly/Conv.h>
-#include <folly/Malloc.h>
 #include <folly/String.h>
+#include <folly/memory/Malloc.h>
 #include <glog/logging.h>
 
 namespace folly {
@@ -91,8 +91,9 @@ bool JemallocNodumpAllocator::extend_and_setup_arena() {
   // Set the custom hook
   extent_hooks_ = *hooks;
   extent_hooks_.alloc = &JemallocNodumpAllocator::alloc;
-  if (auto ret =
-          mallctl(key.c_str(), nullptr, nullptr, &hooks, sizeof(hooks))) {
+  extent_hooks_t* new_hooks = &extent_hooks_;
+  if (auto ret = mallctl(
+          key.c_str(), nullptr, nullptr, &new_hooks, sizeof(new_hooks))) {
     LOG(FATAL) << "Unable to set the hooks: " << errnoStr(ret);
   }
 #endif
@@ -118,6 +119,7 @@ chunk_alloc_t* JemallocNodumpAllocator::original_alloc_ = nullptr;
 void* JemallocNodumpAllocator::alloc(
     void* chunk,
 #else
+extent_hooks_t JemallocNodumpAllocator::extent_hooks_;
 extent_alloc_t* JemallocNodumpAllocator::original_alloc_ = nullptr;
 void* JemallocNodumpAllocator::alloc(
     extent_hooks_t* extent,
@@ -163,4 +165,4 @@ JemallocNodumpAllocator& globalJemallocNodumpAllocator() {
   return *instance;
 }
 
-} // folly
+} // namespace folly