all repos — mgba @ 0a52f44fa822539200f5ae6aad1fe5f5a6a3ab0e

mGBA Game Boy Advance Emulator

Vita: Wait, what do you mean sceKernelFindMemBlockByAddr has been in vitasdk for 4.5 years?
Vicki Pfau vi@endrift.com
Thu, 20 Aug 2020 00:09:20 -0700
commit

0a52f44fa822539200f5ae6aad1fe5f5a6a3ab0e

parent

8a3a2bf058973e01ab332bf58e1173927f4f38f8

1 files changed, 3 insertions(+), 25 deletions(-)

jump to
M src/platform/psp2/psp2-memory.csrc/platform/psp2/psp2-memory.c

@@ -4,22 +4,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public

* License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include <mgba-util/memory.h> -#include <mgba-util/vector.h> #include <psp2/kernel/sysmem.h> #include <psp2/types.h> - -DECLARE_VECTOR(SceUIDList, SceUID); -DEFINE_VECTOR(SceUIDList, SceUID); - -static struct SceUIDList uids; -static bool listInit = false; void* anonymousMemoryMap(size_t size) { - if (!listInit) { - SceUIDListInit(&uids, 8); - listInit = true; - } if (size & 0xFFF) { // Align to 4kB pages size += ((~size) & 0xFFF) + 1;

@@ -28,7 +17,6 @@ SceUID memblock = sceKernelAllocMemBlock("anon", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW, size, 0);

if (memblock < 0) { return 0; } - *SceUIDListAppend(&uids) = memblock; void* ptr; if (sceKernelGetMemBlockBase(memblock, &ptr) < 0) { return 0;

@@ -37,18 +25,8 @@ return ptr;

} void mappedMemoryFree(void* memory, size_t size) { - UNUSED(size); - size_t i; - for (i = 0; i < SceUIDListSize(&uids); ++i) { - SceUID uid = *SceUIDListGetPointer(&uids, i); - void* ptr; - if (sceKernelGetMemBlockBase(uid, &ptr) < 0) { - continue; - } - if (ptr == memory) { - sceKernelFreeMemBlock(uid); - SceUIDListShift(&uids, i, 1); - return; - } + SceUID uid = sceKernelFindMemBlockByAddr(memory, size); + if (uid >= 0) { + sceKernelFreeMemBlock(uid); } }