MicrOS
micros_heap.h
Go to the documentation of this file.
1 #ifndef MICROS_HEAP_H
2 #define MICROS_HEAP_H
3 
4 #include <stdbool.h>
5 #include "micros_interrupts.h"
6 
8 typedef struct micros_heap_entry
9 {
12 
14  uint8_t free;
15 
18 
21 } __attribute__((packed)) micros_heap_entry;
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
28 
35 
37 
43 void *micros_heap_realloc(void *ptr, uint32_t size);
44 
46 
50 void micros_heap_dealloc(void *ptr);
51 
53 
59 
61 
66 
68 
73 
74 
75 //DEBUG
76 void *micros_heap_kernel_alloc(uint32_t size, uint32_t align);
77 void *micros_heap_kernel_dealloc(void* address);
78 
79 #ifdef __cplusplus
80 }
81 #endif
82 
83 #endif
void * micros_heap_realloc(void *ptr, uint32_t size)
Reallocates chunk of memory with the specified size.
Definition: micros_heap.c:8
Structure containing information about application heap and its entries.
Definition: micros_heap.h:8
struct micros_heap_entry * prev
Pointer to the previous entry (0 if first)
Definition: micros_heap.h:20
void * micros_heap_kernel_alloc(uint32_t size, uint32_t align)
Definition: micros_heap.c:33
uint8_t free
Flag indicates if the entry represents some allocated object or not.
Definition: micros_heap.h:14
void * micros_heap_kernel_dealloc(void *address)
Definition: micros_heap.c:38
struct micros_heap_entry * next
Pointer to the next entry (0 if last)
Definition: micros_heap.h:17
uint32_t size
Size of the current entry.
Definition: micros_heap.h:11
void * micros_heap_alloc(uint32_t size, uint32_t align)
Allocates chunk of memory with the specified size and alignment.
Definition: micros_heap.c:3
bool micros_heap_verify_integrity()
Verifies heap integrity.
Definition: micros_heap.c:23
uint32_t micros_heap_get_object_size(void *ptr)
Retrieves size of the heap object.
Definition: micros_heap.c:18
void micros_heap_dealloc(void *ptr)
Deallocates chunk of memory.
Definition: micros_heap.c:13
micros_heap_entry * micros_heap_get_process_heap()
Retrieves application heap.
Definition: micros_heap.c:28
size_t uint32_t
Unsigned integral type.
Definition: string.h:8