Embedded Wireless Framework
ewf_allocator_c_heap.h
Go to the documentation of this file.
1 /************************************************************************/
11 #ifndef __ewf_allocator_c_heap__h__included__
12 #define __ewf_allocator_c_heap__h__included__
13 
14 #include "ewf_allocator.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 /************************************************************************/
30 typedef struct _ewf_allocator_c_heap
31 {
32  uint32_t allocated_count;
33  uint32_t released_count;
34 
35  uint32_t block_count;
36  uint32_t block_size;
39 
40 ewf_result ewf_allocator_c_heap_start(ewf_allocator* allocator_ptr);
41 
42 ewf_result ewf_allocator_c_heap_stop(ewf_allocator* allocator_ptr);
43 
44 ewf_result ewf_allocator_c_heap_allocate(ewf_allocator* allocator_ptr, void** p);
45 
46 ewf_result ewf_allocator_c_heap_release(ewf_allocator* allocator_ptr, void* p);
47 
48 #ifdef EWF_PARAMETER_CHECKING
49 #define EWF_ALLOCATOR_C_HEAP_INITIALIZE_HEADER(allocator_ptr) \
50 do { \
51 (allocator_ptr)->struct_magic = EWF_ALLOCATOR_STRUCT_MAGIC; \
52 (allocator_ptr)->struct_size = EWF_ALLOCATOR_STRUCT_SIZE; \
53 (allocator_ptr)->struct_version = EWF_ALLOCATOR_VERSION; \
54 (allocator_ptr)->struct_type = EWF_ALLOCATOR_TYPE_C_HEAP; \
55 } while(0)
56 #else
57 #define EWF_ALLOCATOR_C_HEAP_INITIALIZE_HEADER(allocator_ptr)
58 #endif /* EWF_PARAMETER_CHECKING */
59 
67 #define EWF_ALLOCATOR_C_HEAP_STATIC_DECLARE(allocator_ptr, allocator_name_symb, block_count_param, block_size_param) \
68 do { \
69 static ewf_allocator_c_heap ewf_allocator_c_heap__##allocator_name_symb = {0}; \
70 static ewf_allocator ewf_allocator__##allocator_name_symb = {0}; \
71 ewf_allocator_c_heap__##allocator_name_symb.block_count = block_count_param; \
72 ewf_allocator_c_heap__##allocator_name_symb.block_size = block_size_param; \
73 ewf_allocator__##allocator_name_symb.start = ewf_allocator_c_heap_start; \
74 ewf_allocator__##allocator_name_symb.stop = ewf_allocator_c_heap_stop; \
75 ewf_allocator__##allocator_name_symb.allocate = ewf_allocator_c_heap_allocate; \
76 ewf_allocator__##allocator_name_symb.release = ewf_allocator_c_heap_release; \
77 ewf_allocator__##allocator_name_symb.implementation_ptr = &(ewf_allocator_c_heap__##allocator_name_symb); \
78 allocator_ptr = &(ewf_allocator__##allocator_name_symb); \
79 EWF_ALLOCATOR_C_HEAP_INITIALIZE_HEADER(allocator_ptr); \
80 } while(0)
81 
82 /************************************************************************/
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 #endif /* __ewf_allocator_c_heap__h__included__ */
struct _ewf_allocator_c_heap ewf_allocator_c_heap
C heap allocator implementation type.
enum _ewf_result ewf_result
Success and error result codes specific to the EWF API.
C heap allocator implementation type.
Definition: ewf_allocator_c_heap.h:31
uint32_t block_size
Definition: ewf_allocator_c_heap.h:36
The allocator structure definition.
Definition: ewf_allocator.h:27