|
|
|
@ -340,8 +340,8 @@ void microbit_free(void *mem)
|
|
|
|
|
if(SERIAL_DEBUG) SERIAL_DEBUG->printf("free: %p\n", mem);
|
|
|
|
|
#endif
|
|
|
|
|
// Sanity check.
|
|
|
|
|
if (memory == NULL)
|
|
|
|
|
return;
|
|
|
|
|
if (memory == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// If this memory was created from a heap registered with us, free it.
|
|
|
|
|
for (int i=0; i < heap_count; i++)
|
|
|
|
@ -349,11 +349,11 @@ void microbit_free(void *mem)
|
|
|
|
|
if(memory > heap[i].heap_start && memory < heap[i].heap_end)
|
|
|
|
|
{
|
|
|
|
|
// The memory block given is part of this heap, so we can simply
|
|
|
|
|
// flag that this memory area is now free, and we're done.
|
|
|
|
|
// flag that this memory area is now free, and we're done.
|
|
|
|
|
if (*cb == 0 || *cb & MICROBIT_HEAP_BLOCK_FREE)
|
|
|
|
|
microbit_panic(MICROBIT_HEAP_ERROR);
|
|
|
|
|
|
|
|
|
|
*cb |= MICROBIT_HEAP_BLOCK_FREE;
|
|
|
|
|
*cb |= MICROBIT_HEAP_BLOCK_FREE;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -427,4 +427,4 @@ int microbit_create_heap(uint32_t start, uint32_t end)
|
|
|
|
|
return MICROBIT_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|