2018-01-25 16:24:33 +00:00
|
|
|
#ifndef LLARP_MEM_H_
|
|
|
|
#define LLARP_MEM_H_
|
2018-05-22 15:54:19 +00:00
|
|
|
#ifdef NO_JEMALLOC
|
2018-05-16 18:13:18 +00:00
|
|
|
#include <stdlib.h>
|
2018-05-22 15:54:19 +00:00
|
|
|
#else
|
|
|
|
#include <jemalloc/jemalloc.h>
|
|
|
|
#endif
|
2018-05-20 16:15:16 +00:00
|
|
|
#include <stdbool.h>
|
2018-05-22 15:54:19 +00:00
|
|
|
#include <stdint.h>
|
2018-05-16 18:13:18 +00:00
|
|
|
|
2017-10-03 19:14:46 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
struct llarp_alloc
|
|
|
|
{
|
|
|
|
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-22 15:54:19 +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-05-20 13:43:42 +00:00
|
|
|
|
|
|
|
/** constant time memcmp */
|
2018-05-22 15:54:19 +00:00
|
|
|
bool
|
|
|
|
llarp_eq(const void *a, const void *b, size_t sz);
|
|
|
|
|
2017-10-03 19:14:46 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|