2018-01-25 16:24:33 +00:00
|
|
|
#ifndef LLARP_MEM_H_
|
|
|
|
#define LLARP_MEM_H_
|
2017-10-03 19:14:46 +00:00
|
|
|
|
2018-05-16 18:13:18 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2017-10-03 19:14:46 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-01-29 14:27:24 +00:00
|
|
|
struct llarp_alloc {
|
2018-05-16 18:13:18 +00:00
|
|
|
void * impl;
|
|
|
|
void *(*alloc)(struct llarp_alloc * mem, size_t sz, size_t align);
|
|
|
|
void (*free)(struct llarp_alloc * mem, void *ptr);
|
2018-01-29 14:27:24 +00:00
|
|
|
};
|
2018-05-16 18:13:18 +00:00
|
|
|
|
|
|
|
void llarp_mem_stdlib(struct llarp_alloc * mem);
|
|
|
|
void llarp_mem_jemalloc(struct llarp_alloc * mem);
|
|
|
|
void llarp_mem_dmalloc(struct llarp_alloc * mem);
|
|
|
|
|
|
|
|
void llarp_mem_slab(struct llarp_alloc * mem, uint32_t * buf, size_t sz);
|
2018-01-29 14:27:24 +00:00
|
|
|
|
2018-05-20 13:43:42 +00:00
|
|
|
|
|
|
|
/** constant time memcmp */
|
|
|
|
bool llarp_eq(const void * a, const void * b, size_t sz);
|
2018-05-16 18:13:18 +00:00
|
|
|
|
2017-10-03 19:14:46 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|