diff --git a/src/system/memory.c b/src/system/memory.c index f6c3b9e..4c48068 100644 --- a/src/system/memory.c +++ b/src/system/memory.c @@ -31,11 +31,6 @@ #define MEMORY_ARENA_8 7 #define MEMORY_ARENA_FG_BUCKET 8 -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Memory functions -//! This is the only place where those are needed so lets keep them more or less private -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - static MEMHeapHandle mem1_heap = NULL; static MEMHeapHandle bucket_heap = NULL; @@ -43,14 +38,16 @@ void memoryInitialize(void) { MEMHeapHandle mem1_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_1); uint32_t mem1_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(mem1_heap_handle, 4); void *mem1_memory = MEMAllocFromFrmHeapEx(mem1_heap_handle, mem1_allocatable_size, 4); - if(mem1_memory) + if(mem1_memory){ mem1_heap = MEMCreateExpHeapEx(mem1_memory, mem1_allocatable_size, 0); + } MEMHeapHandle bucket_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET); uint32_t bucket_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(bucket_heap_handle, 4); void *bucket_memory = MEMAllocFromFrmHeapEx(bucket_heap_handle, bucket_allocatable_size, 4); - if(bucket_memory) + if(bucket_memory){ bucket_heap = MEMCreateExpHeapEx(bucket_memory, bucket_allocatable_size, 0); + } } void memoryRelease(void) { @@ -75,8 +72,9 @@ void MEM2_free(void *ptr) { } void * MEM1_alloc(uint32_t size, uint32_t align) { - if (align < 4) + if (align < 4){ align = 4; + } return MEMAllocFromExpHeapEx(mem1_heap, size, align); } @@ -85,8 +83,9 @@ void MEM1_free(void *ptr) { } void * MEMBucket_alloc(uint32_t size, uint32_t align) { - if (align < 4) + if (align < 4){ align = 4; + } return MEMAllocFromExpHeapEx(bucket_heap, size, align); }