diff options
-rw-r--r-- | backends/gp32/gp32std_memory.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/backends/gp32/gp32std_memory.cpp b/backends/gp32/gp32std_memory.cpp index 0fb54a5d9a..d39d3b95a3 100644 --- a/backends/gp32/gp32std_memory.cpp +++ b/backends/gp32/gp32std_memory.cpp @@ -96,18 +96,22 @@ void MemBlock::deinit() void *MemBlock::addBlock(size_t size) { int i; + MemBlock *blk = &block[prevBlock]; // some optimizaion with loop for (i = prevBlock; i < NUM_BLOCK; i++) { - if (!block[i].used) { + if (!blk->used) { break; } + blk++; } if(i == NUM_BLOCK) { + blk = &block[0]; for (i = 0; i < prevBlock; i++) { - if (!block[i].used) { + if (!blk->used) { break; } + blk++; } if(i == prevBlock) return NULL; @@ -115,9 +119,9 @@ void *MemBlock::addBlock(size_t size) byte *ptr = userMem + (i * USER_BLOCK_SIZE); - block[i].size = size; - block[i].block = ptr; - block[i].used = 1; + blk->size = size; + blk->block = ptr; + blk->used = 1; prevBlock = i; |