2 #ifndef __CORE_ALLOC_H__
3 #define __CORE_ALLOC_H__
8 /* All functions below are wrappers for functions in buflib.h, except
9 * they have a predefined context
11 void core_allocator_init(void);
12 int core_alloc(const char* name
, size_t size
);
13 int core_alloc_ex(const char* name
, size_t size
, struct buflib_callbacks
*ops
);
14 int core_alloc_maximum(const char* name
, size_t *size
, struct buflib_callbacks
*ops
);
15 bool core_shrink(int handle
, void* new_start
, size_t new_size
);
16 void core_free(int handle
);
17 size_t core_available(void);
19 /* DO NOT ADD wrappers for buflib_buffer_out/in. They do not call
20 * the move callbacks and are therefore unsafe in the core */
22 #ifdef BUFLIB_DEBUG_BLOCKS
23 void core_print_allocs(void (*print
)(const char*));
24 void core_print_blocks(void (*print
)(const char*));
26 #ifdef BUFLIB_DEBUG_BLOCK_SINGLE
27 int core_get_num_blocks(void);
28 void core_print_block_at(int block_num
, char* buf
, size_t bufsize
);
31 static inline void* core_get_data(int handle
)
33 extern struct buflib_context core_ctx
;
34 return buflib_get_data(&core_ctx
, handle
);
36 #endif /* __CORE_ALLOC_H__ */