#ifndef ZABBIX_MEMALLOC_H
#define ZABBIX_MEMALLOC_H
#define MEM_MIN_BUCKET_SIZE MEM_MIN_ALLOC
#define MEM_MAX_BUCKET_SIZE 256
#define MEM_BUCKET_COUNT ((MEM_MAX_BUCKET_SIZE - MEM_MIN_BUCKET_SIZE) / 8 + 1)
zbx_uint64_t min_chunk_size;
zbx_uint64_t max_chunk_size;
unsigned int chunks_num[MEM_BUCKET_COUNT];
unsigned int free_chunks;
unsigned int used_chunks;
int zbx_mem_create(zbx_mem_info_t **info, zbx_uint64_t size, const char *descr, const char *param, int allow_oom,
#define zbx_mem_malloc(info, old, size) __zbx_mem_malloc(__FILE__, __LINE__, info, old, size)
#define zbx_mem_realloc(info, old, size) __zbx_mem_realloc(__FILE__, __LINE__, info, old, size)
#define zbx_mem_free(info, ptr) \
__zbx_mem_free(__FILE__, __LINE__, info, ptr); \
void *__zbx_mem_malloc(const char *file, int line, zbx_mem_info_t *info, const void *old, size_t size);
void *__zbx_mem_realloc(const char *file, int line, zbx_mem_info_t *info, void *old, size_t size);
void __zbx_mem_free(const char *file, int line, zbx_mem_info_t *info, void *ptr);
void zbx_mem_clear(zbx_mem_info_t *info);
void zbx_mem_get_stats(const zbx_mem_info_t *info, zbx_mem_stats_t *stats);
void zbx_mem_dump_stats(int level, zbx_mem_info_t *info);
size_t zbx_mem_required_size(int chunks_num, const char *descr, const char *param);
zbx_uint64_t zbx_mem_required_chunk_size(zbx_uint64_t size);