Adds FRLG asserts to Alloc/Free (#7025)

This commit is contained in:
cawtds 2025-06-01 15:22:00 +02:00 committed by GitHub
parent 8697bef20c
commit d3af14b2bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -101,6 +101,11 @@ void *AllocInternal(void *heapStart, u32 size, const char *location)
while (block != head);
Test_ExitWithResult(TEST_RESULT_ERROR, SourceLine(0), ":L%s:%d, %s: OOM allocating %d bytes", gTestRunnerState.test->filename, SourceLine(0), location, size);
#endif
if (location)
{
DebugPrintfLevel(MGBA_LOG_ERROR, "%s: out of memory trying to allocate %d bytes", location, size);
}
AGB_ASSERT(FALSE);
return NULL;
}
@ -114,6 +119,8 @@ void FreeInternal(void *heapStart, void *pointer)
{
struct MemBlock *head = (struct MemBlock *)heapStart;
struct MemBlock *block = (struct MemBlock *)((u8 *)pointer - sizeof(struct MemBlock));
AGB_ASSERT(block->magic == MALLOC_SYSTEM_ID);
AGB_ASSERT(block->allocated == TRUE);
block->allocated = FALSE;
// If the freed block isn't the last one, merge with the next block
@ -136,6 +143,8 @@ void FreeInternal(void *heapStart, void *pointer)
{
if (!block->prev->allocated)
{
AGB_ASSERT(block->prev->magic == MALLOC_SYSTEM_ID);
block->prev->next = block->next;
if (block->next != head)