Move bin2c handling to libtools.make
[maemo-rb.git] / firmware / include / core_alloc.h
blobd234947db1eadbadeb25585dd4f7411a1ffe1b67
2 #ifndef __CORE_ALLOC_H__
3 #define __CORE_ALLOC_H__
4 #include <string.h>
5 #include <stdbool.h>
6 #include "config.h"
7 #include "buflib.h"
9 /* All functions below are wrappers for functions in buflib.h, except
10 * they have a predefined context
12 void core_allocator_init(void) INIT_ATTR;
13 int core_alloc(const char* name, size_t size);
14 int core_alloc_ex(const char* name, size_t size, struct buflib_callbacks *ops);
15 int core_alloc_maximum(const char* name, size_t *size, struct buflib_callbacks *ops);
16 bool core_shrink(int handle, void* new_start, size_t new_size);
17 int core_free(int handle);
18 size_t core_available(void);
20 /* DO NOT ADD wrappers for buflib_buffer_out/in. They do not call
21 * the move callbacks and are therefore unsafe in the core */
23 #ifdef BUFLIB_DEBUG_BLOCKS
24 void core_print_allocs(void (*print)(const char*));
25 void core_print_blocks(void (*print)(const char*));
26 #endif
27 #ifdef BUFLIB_DEBUG_BLOCK_SINGLE
28 int core_get_num_blocks(void);
29 void core_print_block_at(int block_num, char* buf, size_t bufsize);
30 #endif
32 /* frees the debug test alloc created at initialization,
33 * since this is the first any further alloc should force a compaction run */
34 bool core_test_free(void);
36 static inline void* core_get_data(int handle)
38 extern struct buflib_context core_ctx;
39 return buflib_get_data(&core_ctx, handle);
42 static inline const char* core_get_name(int handle)
44 extern struct buflib_context core_ctx;
45 return buflib_get_name(&core_ctx, handle);
48 #endif /* __CORE_ALLOC_H__ */