3 #include "core_alloc.h"
7 /* not static so it can be discovered by core_get_data() */
8 struct buflib_context core_ctx
;
10 void core_allocator_init(void)
14 void *start
= buffer_get_buffer(&size
);
15 buflib_init(&core_ctx
, start
, size
);
16 buffer_release_buffer(size
);
19 int core_alloc(const char* name
, size_t size
)
21 return buflib_alloc_ex(&core_ctx
, size
, name
, NULL
);
24 int core_alloc_ex(const char* name
, size_t size
, struct buflib_callbacks
*ops
)
26 return buflib_alloc_ex(&core_ctx
, size
, name
, ops
);
29 size_t core_available(void)
31 return buflib_available(&core_ctx
);
34 void core_free(int handle
)
36 buflib_free(&core_ctx
, handle
);
39 int core_alloc_maximum(const char* name
, size_t *size
, struct buflib_callbacks
*ops
)
41 return buflib_alloc_maximum(&core_ctx
, name
, size
, ops
);
44 bool core_shrink(int handle
, void* new_start
, size_t new_size
)
46 return buflib_shrink(&core_ctx
, handle
, new_start
, new_size
);
49 int core_get_num_blocks(void)
51 return buflib_get_num_blocks(&core_ctx
);
54 void core_print_block_at(int block_num
, char* buf
, size_t bufsize
)
56 buflib_print_block_at(&core_ctx
, block_num
, buf
, bufsize
);