Fix playlist catalog directory manual spelling
[maemo-rb.git] / firmware / include / core_alloc.h
blob0ac7e5b73d4677d3863fc95ff57fa3ce03649d0f
2 #ifndef __CORE_ALLOC_H__
3 #define __CORE_ALLOC_H__
4 #include <string.h>
5 #include <stdbool.h>
6 #include "buflib.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 int 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*));
25 #endif
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);
29 #endif
31 /* frees the debug test alloc created at initialization,
32 * since this is the first any further alloc should force a compaction run */
33 bool core_test_free(void);
35 static inline void* core_get_data(int handle)
37 extern struct buflib_context core_ctx;
38 return buflib_get_data(&core_ctx, handle);
41 static inline const char* core_get_name(int handle)
43 extern struct buflib_context core_ctx;
44 return buflib_get_name(&core_ctx, handle);
47 #endif /* __CORE_ALLOC_H__ */