mirror of
https://github.com/wiiu-env/MemoryMappingModule.git
synced 2024-11-22 09:49:20 +01:00
The allocated size is now always an integral multiple of alignment.
This commit is contained in:
parent
f513e1a374
commit
79787e7dce
@ -395,9 +395,6 @@ void MemoryMapping_setupMemoryMapping() {
|
|||||||
OSInitMutex(&allocMutex);
|
OSInitMutex(&allocMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ROUNDDOWN(val, align) ((val) & ~(align - 1))
|
|
||||||
#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align - 1)), align)
|
|
||||||
|
|
||||||
void *MemoryMapping_allocEx(uint32_t size, int32_t align, bool videoOnly) {
|
void *MemoryMapping_allocEx(uint32_t size, int32_t align, bool videoOnly) {
|
||||||
OSLockMutex(&allocMutex);
|
OSLockMutex(&allocMutex);
|
||||||
void *res = nullptr;
|
void *res = nullptr;
|
||||||
@ -414,10 +411,7 @@ void *MemoryMapping_allocEx(uint32_t size, int32_t align, bool videoOnly) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We round up the size to avoid heap corruption.
|
res = MEMAllocFromExpHeapEx(heapHandle, (size + align - 1) & ~(align - 1), align);
|
||||||
// FSReadFile expects the buffer size to be a multiple of 0x40
|
|
||||||
// This can remove once all modules/plugins have been updated :)
|
|
||||||
res = MEMAllocFromExpHeapEx(heapHandle, ROUNDUP(size, 0x40), align);
|
|
||||||
if (res != nullptr) {
|
if (res != nullptr) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user