mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-15 12:13:24 +00:00
40 lines
589 B
C++
40 lines
589 B
C++
#define NO_JEMALLOC
|
|
#include <llarp/mem.h>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
|
|
namespace llarp
|
|
{
|
|
void *
|
|
std_malloc(struct llarp_alloc *mem, size_t sz, size_t align)
|
|
{
|
|
(void)mem;
|
|
(void)align;
|
|
void *ptr = malloc(sz);
|
|
if(ptr)
|
|
{
|
|
std::memset(ptr, 0, sz);
|
|
return ptr;
|
|
}
|
|
abort();
|
|
}
|
|
|
|
void
|
|
std_free(struct llarp_alloc *mem, void *ptr)
|
|
{
|
|
(void)mem;
|
|
if(ptr)
|
|
free(ptr);
|
|
}
|
|
|
|
} // namespace llarp
|
|
|
|
extern "C" {
|
|
void
|
|
llarp_mem_stdlib(struct llarp_alloc *mem)
|
|
{
|
|
mem->alloc = llarp::std_malloc;
|
|
mem->free = llarp::std_free;
|
|
}
|
|
}
|