#ifndef BOMALLOC_H
#define BOMALLOC_H
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define BO_ALLOCATOR_ABI_VERSION 1u
#define BO_OK 0
#define BO_ENOMEM 12
#define BO_EINVAL 22
#define BO_EUNSUPPORTED 1001
#define BO_EINVARIANT 1002
#define BO_EPANIC 1003
#define BO_TRIM_EXCESS 0u
#define BO_TRIM_AGGRESSIVE 1u
typedef struct bo_stats_v1 {
uint32_t abi_version;
uint32_t struct_size;
uint64_t reserved_bytes;
uint64_t committed_bytes;
uint64_t requested_live_bytes;
uint64_t usable_live_bytes;
uint64_t metadata_bytes;
uint64_t c_header_bytes_per_allocation;
uint64_t c_default_alignment;
uint64_t green_spans;
uint64_t white_spans;
uint64_t red_spans;
uint64_t black_spans;
uint64_t splits;
uint64_t merges;
uint64_t steals;
uint64_t cas_failures;
uint64_t random_jumps;
uint64_t decommits;
uint64_t chunk_releases;
} bo_stats_v1;
typedef struct bo_trim_stats_v1 {
uint32_t abi_version;
uint32_t struct_size;
uint64_t spans_reclaimed;
uint64_t bytes_decommitted;
uint64_t chunks_released;
uint64_t bytes_released;
} bo_trim_stats_v1;
#if defined(__cplusplus)
static_assert(sizeof(bo_stats_v1) == 152, "unexpected bo_stats_v1 layout");
static_assert(sizeof(bo_trim_stats_v1) == 40, "unexpected bo_trim_stats_v1 layout");
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
_Static_assert(sizeof(bo_stats_v1) == 152, "unexpected bo_stats_v1 layout");
_Static_assert(sizeof(bo_trim_stats_v1) == 40, "unexpected bo_trim_stats_v1 layout");
#endif
uint32_t bo_allocator_abi_version(void);
int32_t bo_allocator_initialize(void);
void *bo_malloc(size_t size);
void *bo_calloc(size_t count, size_t size);
void *bo_aligned_alloc(size_t alignment, size_t size);
int32_t bo_posix_memalign(void **output, size_t alignment, size_t size);
void *bo_realloc(void *pointer, size_t new_size);
void *bo_reallocarray(void *pointer, size_t count, size_t size);
void bo_free(void *pointer);
size_t bo_malloc_usable_size(void *pointer);
int32_t bo_allocator_stats_v1(bo_stats_v1 *output);
int32_t bo_allocator_trim_v1(uint32_t mode, bo_trim_stats_v1 *output);
int32_t bo_allocator_validate(void);
#ifdef __cplusplus
}
#endif
#endif