Implementing resize of heap blocks.

- adding mem_heap_try_resize_block routine that tries to resize
   block using free space that is located right after the resized block;
 - placing long-term blocks from start of heap space and short-term - from end
   of the space to increase probability of success of resizing just allocated
   long-term block;
 - adding mem_heap_try_resize_block invocation to 'test_heap' unit test.
This commit is contained in:
Ruben Ayrapetyan
2014-11-11 15:25:19 +03:00
parent 4875762cfc
commit bd60d1874b
3 changed files with 164 additions and 7 deletions
+1
View File
@@ -42,6 +42,7 @@ typedef enum
extern void mem_heap_init (uint8_t *heap_start, size_t heap_size);
extern void mem_heap_finalize (void);
extern uint8_t* mem_heap_alloc_block (size_t size_in_bytes, mem_heap_alloc_term_t alloc_term);
extern bool mem_heap_try_resize_block (uint8_t *ptr, size_t size_in_bytes);
extern void mem_heap_free_block (uint8_t *ptr);
extern size_t mem_heap_recommend_allocation_size (size_t minimum_allocation_size);
extern void mem_heap_print (bool dump_block_headers, bool dump_block_data, bool dump_stats);