lokinet/llarp/mem_jemalloc.cpp

22 lines
482 B
C++
Raw Normal View History

2017-10-03 19:14:46 +00:00
#include <jemalloc/jemalloc.h>
2018-01-29 14:27:24 +00:00
#include <llarp/mem.h>
2017-10-03 19:14:46 +00:00
2018-01-29 14:27:24 +00:00
namespace llarp {
2018-05-16 18:13:18 +00:00
static void *jem_malloc(struct llarp_alloc * mem, size_t sz, size_t align) {
(void) mem;
return mallocx(sz, MALLOCX_ALIGN(align));
}
2017-10-03 19:14:46 +00:00
2018-05-16 18:13:18 +00:00
static void jem_free(struct llarp_alloc * mem, void *ptr) {
(void) mem;
if (ptr) free(ptr);
}
2018-02-01 13:21:00 +00:00
} // namespace llarp
2017-10-03 19:14:46 +00:00
extern "C" {
2018-05-16 18:13:18 +00:00
void llarp_mem_jemalloc(struct llarp_alloc * mem) {
mem->alloc = llarp::jem_malloc;
mem->free = llarp::jem_free;
2018-01-29 14:27:24 +00:00
}
2017-10-03 19:14:46 +00:00
}