From 61e240f48274476fd54fe4bd5d6ccb7ee13448cb Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 25 Aug 2013 13:35:53 -0700 Subject: [PATCH] Allocate fpl blocks in a ring, like the PSP. --- Core/HLE/sceKernelMemory.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index 42510d8ad8..a1fea46033 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -69,7 +69,7 @@ struct NativeFPL //FPL - Fixed Length Dynamic Memory Pool - every item has the same length struct FPL : public KernelObject { - FPL() : blocks(NULL) {} + FPL() : blocks(NULL), nextBlock(0) {} ~FPL() { if (blocks != NULL) { delete [] blocks; @@ -83,8 +83,10 @@ struct FPL : public KernelObject int findFreeBlock() { for (int i = 0; i < nf.numBlocks; i++) { - if (!blocks[i]) - return i; + int b = nextBlock++ % nf.numBlocks; + if (!blocks[b]) { + return b; + } } return -1; } @@ -112,6 +114,7 @@ struct FPL : public KernelObject p.DoArray(blocks, nf.numBlocks); p.Do(address); p.Do(alignedSize); + p.Do(nextBlock); FplWaitingThread dv = {0}; p.Do(waitingThreads, dv); p.DoMarker("FPL"); @@ -121,6 +124,7 @@ struct FPL : public KernelObject bool *blocks; u32 address; int alignedSize; + int nextBlock; std::vector waitingThreads; };