mirror of
https://github.com/SpeedBreakerProject/speedbreaker.git
synced 2026-10-18 00:02:34 +02:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
908 B
C++
42 lines
908 B
C++
// Adapted from Unleashed Recompiled (https://github.com/hedge-dev/UnleashedRecomp),
|
|
// GPL-3.0-or-later. Modified for SpeedBreaker.
|
|
#pragma once
|
|
|
|
#include <mutex.h>
|
|
#include <o1heap.h>
|
|
|
|
struct Heap
|
|
{
|
|
Mutex mutex;
|
|
O1HeapInstance* heap;
|
|
|
|
Mutex physicalMutex;
|
|
O1HeapInstance* physicalHeap;
|
|
|
|
void Init();
|
|
|
|
void* Alloc(size_t size);
|
|
void* AllocPhysical(size_t size, size_t alignment);
|
|
void Free(void* ptr);
|
|
|
|
size_t Size(void* ptr);
|
|
|
|
template<typename T, typename... Args>
|
|
T* Alloc(Args&&... args)
|
|
{
|
|
T* obj = (T*)Alloc(sizeof(T));
|
|
new (obj) T(std::forward<Args>(args)...);
|
|
return obj;
|
|
}
|
|
|
|
template<typename T, typename... Args>
|
|
T* AllocPhysical(Args&&... args)
|
|
{
|
|
T* obj = (T*)AllocPhysical(sizeof(T), alignof(T));
|
|
new (obj) T(std::forward<Args>(args)...);
|
|
return obj;
|
|
}
|
|
};
|
|
|
|
extern Heap g_userHeap;
|