diff options
| author | Elijah Thomas <42302100+elijah-thomas774@users.noreply.github.com> | 2024-05-05 13:08:09 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-05 13:08:09 -0400 |
| commit | 126c5db9431bef2b6f032bce673d7c3d61e62aa3 (patch) | |
| tree | 21d36315dc8c6fe3ed50e583367dcc554be687f2 /include | |
| parent | 745f34f8f0bb14d56c1ba11d2ffc835bf916ed75 (diff) | |
| parent | 944a5315c6735ac88e437755e7137a6d1d154135 (diff) | |
Merge pull request #32 from robojumper/eggExpHeap
eggExpHeap matching
Diffstat (limited to 'include')
| -rw-r--r-- | include/egg/core/eggExpHeap.h | 7 | ||||
| -rw-r--r-- | include/egg/core/eggHeap.h | 20 | ||||
| -rw-r--r-- | include/rvl/MEM/mem_expHeap.h | 8 |
3 files changed, 22 insertions, 13 deletions
diff --git a/include/egg/core/eggExpHeap.h b/include/egg/core/eggExpHeap.h index 2cfc534d..69b35128 100644 --- a/include/egg/core/eggExpHeap.h +++ b/include/egg/core/eggExpHeap.h @@ -24,7 +24,12 @@ public: /* 80495b70 */ static ExpHeap *create(void *block, size_t size, u16 attr); /* 80495c30 */ static ExpHeap *create(size_t size, Heap *heap, u16 attr); /* 80495d00 */ void setGroupID(u16 groupId); - /* 80495f80 */ u32 getSizeForMBlock(const void *block); + /* 80495f80 */ static u32 getSizeForMBlock(const void *block); + + // Placement new for ::create + inline void *operator new(size_t size, void *ptr) { + return ptr; + } }; } // namespace EGG diff --git a/include/egg/core/eggHeap.h b/include/egg/core/eggHeap.h index 969fc229..8d9ce935 100644 --- a/include/egg/core/eggHeap.h +++ b/include/egg/core/eggHeap.h @@ -18,12 +18,12 @@ class Allocator; struct HeapAllocArg { void *userArg; // 00 - u32 size; // 04 - int align; // 08 - Heap *heap; // 0C heap to allocate in - int another; // 10 + u32 size; // 04 + int align; // 08 + void *ptr; // 0C the allocated ptr + Heap *heap; // 10 heap to allocate in - inline HeapAllocArg() : userArg(0), size(0), align(0), heap(nullptr) {} + inline HeapAllocArg() : userArg(0), size(0), align(0), heap(nullptr), ptr(nullptr) {} }; typedef void (*HeapAllocCallback)(HeapAllocArg *arg); @@ -37,8 +37,8 @@ typedef void (*ErrorCallback)(HeapErrorArg *); struct HeapFreeArg { void *userArg; - int arg1; - int arg2; + void *ptr; + Heap *heap; }; typedef void (*HeapFreeCallback)(HeapFreeArg *); @@ -57,14 +57,14 @@ public: // vtable at 0x0 | 8056e950 /* vt 0x08 | 804954c0 */ virtual ~Heap(); /* vt 0x0C | 00000000 */ virtual eHeapKind getHeapKind() const = 0; - /* vt 0x10 | 80495a40 */ virtual void initAllocator(Allocator *allocator, s32 align) = 0; + /* vt 0x10 | 80495a40 */ virtual void initAllocator(Allocator *allocator, s32 align); /* vt 0x14 | 00000000 */ virtual void *alloc(u32 size, s32 align) = 0; /* vt 0x18 | 00000000 */ virtual void free(void *block) = 0; /* vt 0x1C | 00000000 */ virtual void destroy() = 0; /* vt 0x20 | 00000000 */ virtual u32 resizeForMBlock(void *block, u32 size) = 0; /* vt 0x24 | 00000000 */ virtual u32 getTotalFreeSize() = 0; - /* vt 0x24 | 00000000 */ virtual u32 getAllocatableSize(s32 align) = 0; - /* vt 0x28 | 00000000 */ virtual u32 adjust() = 0; + /* vt 0x28 | 00000000 */ virtual u32 getAllocatableSize(s32 align) = 0; + /* vt 0x2C | 00000000 */ virtual u32 adjust() = 0; public: void setName(const char *name) { diff --git a/include/rvl/MEM/mem_expHeap.h b/include/rvl/MEM/mem_expHeap.h index 2a8cbe88..bdf9e79a 100644 --- a/include/rvl/MEM/mem_expHeap.h +++ b/include/rvl/MEM/mem_expHeap.h @@ -53,8 +53,11 @@ struct MEMiHeapHead *MEMDestroyExpHeap(struct MEMiHeapHead *heap); void *MEMAllocFromExpHeapEx(struct MEMiHeapHead *heap, u32 size, s32 align); u32 MEMResizeForMBlockExpHeap(struct MEMiHeapHead *heap, void *memBlock, u32 size); void MEMFreeToExpHeap(struct MEMiHeapHead *heap, void *memBlock); +u32 MEMGetAllocatableSizeForExpHeap(struct MEMiHeapHead *heap); u32 MEMGetAllocatableSizeForExpHeapEx(struct MEMiHeapHead *heap, s32 align); +void MEMSetGroupIdForExpHeap(MEMiHeapHead *mHeapHandle, u16 groupId); u32 MEMAdjustExpHeap(struct MEMiHeapHead *heap); +u32 MEMGetSizeForMBlockExpHeap(const void *block); static inline struct MEMiHeapHead *MEMCreateExpHeap(void *start, u32 size) { return MEMCreateExpHeapEx(start, size, 0); @@ -63,10 +66,11 @@ static inline struct MEMiHeapHead *MEMCreateExpHeap(void *start, u32 size) { static inline void *MEMAllocFromExpHeap(struct MEMiHeapHead *heap, u32 size) { return MEMAllocFromExpHeapEx(heap, size, 4); } - +// This doesn't appear to be inline in SS yet +/* static inline u32 MEMGetAllocatableSizeForExpHeap(struct MEMiHeapHead *heap) { return MEMGetAllocatableSizeForExpHeapEx(heap, 4); -} +}*/ #ifdef __cplusplus } |
