futriix/src/new.cpp
John Sully 9f37260413 Fix crash when using rocksdb and jemalloc but scope it to just jemalloc
Former-commit-id: 6fa0cfd35fd1158f190db27bfb734ea2f763cb20
2019-12-19 15:44:09 -05:00

41 lines
654 B
C++

#include <cstddef> // std::size_t
#include "server.h"
#include "new.h"
#ifdef SANITIZE
void *operator new(size_t size, enum MALLOC_CLASS mclass)
{
(void)mclass;
return ::operator new(size);
}
#else
[[deprecated]]
void *operator new(size_t size)
{
return zmalloc(size, MALLOC_LOCAL);
}
void *operator new(size_t size, enum MALLOC_CLASS mclass)
{
return zmalloc(size, mclass);
}
void operator delete(void * p) noexcept
{
zfree(p);
}
void operator delete(void *p, std::size_t) noexcept
{
zfree(p);
}
#endif
#if defined(USE_JEMALLOC)
extern "C" size_t malloc_usable_size(void *ptr)
{
return zmalloc_usable(ptr);
}
#endif