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_std.cpp

29 lines
507 B
C++

7 years ago
#include <llarp/mem.h>
7 years ago
#include <cstring>
7 years ago
7 years ago
namespace llarp {
6 years ago
void *std_malloc(struct llarp_alloc *mem, size_t sz, size_t align) {
(void)mem;
7 years ago
(void)align;
void *ptr = malloc(sz);
7 years ago
if (ptr) {
7 years ago
std::memset(ptr, 0, sz);
return ptr;
}
7 years ago
abort();
}
7 years ago
6 years ago
void std_free(struct llarp_alloc * mem, void *ptr) {
(void) mem;
7 years ago
if (ptr) free(ptr);
7 years ago
}
7 years ago
} // namespace llarp
7 years ago
7 years ago
extern "C" {
6 years ago
void llarp_mem_stdlib(struct llarp_alloc * mem) {
mem->alloc = llarp::std_malloc;
mem->free = llarp::std_free;
7 years ago
}
7 years ago
}