#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 {
}
// Set the custom hook
- hooks->alloc = &JemallocNodumpAllocator::alloc;
+ extent_hooks_ = *hooks;
+ extent_hooks_.alloc = &JemallocNodumpAllocator::alloc;
+ 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
return true;
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,
return *instance;
}
-} // folly
+} // namespace folly