lokinet/llarp/mem_std.cpp

40 lines
589 B
C++
Raw Normal View History

#define NO_JEMALLOC
2018-01-25 16:24:33 +00:00
#include <llarp/mem.h>
#include <cstdlib>
2018-04-04 16:10:27 +00:00
#include <cstring>
2017-10-03 19:14:46 +00:00
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();
2018-04-04 16:10:27 +00:00
}
2017-10-03 19:14:46 +00:00
void
std_free(struct llarp_alloc *mem, void *ptr)
{
(void)mem;
if(ptr)
free(ptr);
}
2017-10-03 19:14:46 +00:00
2018-02-01 13:21:00 +00:00
} // namespace llarp
2018-01-29 14:27:24 +00:00
2017-10-03 19:14:46 +00:00
extern "C" {
void
llarp_mem_stdlib(struct llarp_alloc *mem)
{
2018-05-16 18:13:18 +00:00
mem->alloc = llarp::std_malloc;
mem->free = llarp::std_free;
2018-01-29 14:27:24 +00:00
}
2017-10-03 19:14:46 +00:00
}