diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index 3b358ff3fc..fdef16f594 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -765,7 +765,7 @@ void SavedataParam::SetFileInfo(int idx, PSPFileInfo &info, std::string saveName u32 atlasPtr; if (success) atlasPtr = kernelMemory.Alloc(texSize, true, "SaveData Icon"); - if (success && atlasPtr > 0) + if (success && atlasPtr != -1) { saveDataList[idx].textureData = atlasPtr; Memory::Memcpy(atlasPtr, textureData, texSize); diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index c5b454a36f..6d8f426c30 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -355,7 +355,7 @@ public: { stackBlock = userMemory.Alloc(stackSize, true, (std::string("stack/") + nt.name).c_str()); } - if (stackBlock == (u32)-1 || stackBlock == 0) + if (stackBlock == (u32)-1) { stackBlock = 0; ERROR_LOG(HLE, "Failed to allocate stack for thread"); diff --git a/Core/Util/BlockAllocator.cpp b/Core/Util/BlockAllocator.cpp index c8e7cbbe3e..8158ff7966 100644 --- a/Core/Util/BlockAllocator.cpp +++ b/Core/Util/BlockAllocator.cpp @@ -32,7 +32,7 @@ u32 BlockAllocator::Alloc(u32 &size, bool fromTop, const char *tag) // Sanity check if (size == 0 || size > rangeSize_) { ERROR_LOG(HLE, "Clearly bogus size: %08x - failing allocation", size); - return 0; + return -1; } // upalign size to grain @@ -104,7 +104,7 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag) CheckBlocks(); if (size > rangeSize_) { ERROR_LOG(HLE, "Clearly bogus size: %08x - failing allocation", size); - return 0; + return -1; } // upalign size to grain diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index b9ad159334..d18fda45f1 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -97,6 +97,14 @@ static void EndVertexDataAndDraw(int prim) { WriteCmd(GE_CMD_PRIM, (prim << 16) | vertexCount); } +static u32 __PPGeDoAlloc(u32 &size, bool fromTop, const char *name) { + u32 ptr = kernelMemory.Alloc(size, fromTop, name); + // Didn't get it. + if (ptr == -1) + return 0; + return ptr; +} + void __PPGeInit() { if (PSP_CoreParameter().gpuCore == GPU_NULL) { @@ -117,10 +125,10 @@ void __PPGeInit() u32 atlasSize = height * width * 2; // it's a 4444 texture atlasWidth = width; atlasHeight = height; - dlPtr = kernelMemory.Alloc(dlSize, false, "PPGe Display List"); - dataPtr = kernelMemory.Alloc(dataSize, false, "PPGe Vertex Data"); - atlasPtr = kernelMemory.Alloc(atlasSize, false, "PPGe Atlas Texture"); - savedContextPtr = kernelMemory.Alloc(savedContextSize, false, "PPGe Saved Context"); + dlPtr = __PPGeDoAlloc(dlSize, false, "PPGe Display List"); + dataPtr = __PPGeDoAlloc(dataSize, false, "PPGe Vertex Data"); + atlasPtr = __PPGeDoAlloc(atlasSize, false, "PPGe Atlas Texture"); + savedContextPtr = __PPGeDoAlloc(savedContextSize, false, "PPGe Saved Context"); u16 *imagePtr = (u16 *)imageData; // component order change