You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lokinet/llarp/mem_jemalloc.cpp

36 lines
643 B
C++

7 years ago
#include <sarp/mem.h>
#include <jemalloc/jemalloc.h>
namespace sarp
{
static void * jem_malloc(size_t sz)
{
return mallocx(sz, MALLOCX_ZERO);
}
static void jem_free(void * ptr)
{
if(ptr) free(ptr);
}
static void * jem_calloc(size_t n, size_t sz)
{
return mallocx(n * sz, MALLOCX_ZERO);
}
static void * jem_realloc(void * ptr, size_t sz)
{
return rallocx(ptr, sz, MALLOCX_ZERO);
}
}
extern "C" {
7 years ago
void sarp_mem_jemalloc()
7 years ago
{
7 years ago
sarp_g_mem.malloc = sarp::jem_malloc;
sarp_g_mem.free = sarp::jem_free;
sarp_g_mem.calloc = sarp::jem_calloc;
sarp_g_mem.realloc = sarp::jem_realloc;
7 years ago
}
}