There is a bug in:
void Mem_DynamicAlloc(u16 size)
The bug is here:
struct MemChunkHeader newChunk = (struct MemChunkHeader*)(chunk + needSize); // New free sub-chunk
chunk has to be converted to u16 or you allocate 4 times more bytes. This is the fix
There is a bug in: void Mem_DynamicAlloc(u16 size) The bug is here: struct MemChunkHeader newChunk = (struct MemChunkHeader*)(chunk + needSize); // New free sub-chunk chunk has to be converted to u16 or you allocate 4 times more bytes. This is the fix
struct SptChunkHeader newChunk = (struct SptChunkHeader)(((u16)chunk) + needSize); // New free sub-chunk