mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-12 05:28:43 -04:00
Fix getMaxAllocatableSize & CMemBlock::getBlock on 64-bit
This commit is contained in:
@@ -35,7 +35,7 @@ public:
|
||||
CMemBlock* getNextBlock() const { return mNext; }
|
||||
u32 getSize() const { return size; }
|
||||
u8 getGroupId() const { return mGroupId; }
|
||||
static CMemBlock* getBlock(void* data) { return (CMemBlock*)((uintptr_t)data + -0x10); }
|
||||
static CMemBlock* getBlock(void* data) { return (CMemBlock*)((uintptr_t)data + -sizeof(CMemBlock)); }
|
||||
|
||||
private:
|
||||
/* 0x0 */ u16 mMagic;
|
||||
@@ -44,9 +44,17 @@ public:
|
||||
/* 0x4 */ u32 size;
|
||||
/* 0x8 */ CMemBlock* mPrev;
|
||||
/* 0xC */ CMemBlock* mNext;
|
||||
#if BIT_64
|
||||
// Ensure padded to 0x20 bytes on 64-bit
|
||||
void* _pad;
|
||||
#endif
|
||||
}; // Size: 0x10
|
||||
friend class CMemBlock;
|
||||
|
||||
#if TARGET_PC
|
||||
static_assert(sizeof(CMemBlock) == MEM_BLOCK_SIZE);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
JKRExpHeap(void* data, u32 size, JKRHeap* parent, bool errorFlag);
|
||||
virtual ~JKRExpHeap();
|
||||
|
||||
@@ -16,6 +16,12 @@ extern u8 JKRValue_DEBUGFILL_DELETE;
|
||||
extern s32 fillcheck_dispcount;
|
||||
extern bool data_8074A8D0_debug;
|
||||
|
||||
#if BIT_64
|
||||
#define MEM_BLOCK_SIZE 0x20
|
||||
#else
|
||||
#define MEM_BLOCK_SIZE 0x10
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-jkernel
|
||||
*
|
||||
|
||||
@@ -313,8 +313,8 @@ u8 JKRHeap::getCurrentGroupId() {
|
||||
}
|
||||
|
||||
u32 JKRHeap::getMaxAllocatableSize(int alignment) {
|
||||
u32 maxFreeBlock = (uintptr_t)getMaxFreeBlock();
|
||||
u32 ptrOffset = (alignment - 1) & alignment - (maxFreeBlock & 0xf);
|
||||
uintptr_t maxFreeBlock = (uintptr_t)getMaxFreeBlock();
|
||||
uintptr_t ptrOffset = (alignment - 1) & alignment - (maxFreeBlock & (MEM_BLOCK_SIZE - 1));
|
||||
return ~(alignment - 1) & (getFreeSize() - ptrOffset);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user