Yes, that's fair enough (though I prefer static allocation when possible
- it makes it easier to see memory usage in map files. And for less capable microcontrollers, it can be more efficient).
I have used systems where the malloc/free system is implemented as something like :
static uint8_t heap[HEAP_SIZE]; static uint8_t * heapPointer;
void * malloc(size_t size) { if ((&heap[HEAP_SIZE] - heapPointer) < size) { die_horribly(); } uint8_t * p = heapPointer; heapPointer += size; return p; }
void free(void * ptr) { die_horribly(); }