feat(objectalloc): implement copy constructor for CObjectHeap

This commit is contained in:
VDm 2025-08-23 14:48:13 +04:00
parent 199a2c46cb
commit 5d0182796e
2 changed files with 17 additions and 3 deletions

View file

@ -4,6 +4,18 @@
#include <bc/Memory.hpp> #include <bc/Memory.hpp>
#include <storm/Error.hpp> #include <storm/Error.hpp>
CObjectHeap::CObjectHeap(const CObjectHeap& heap) {
if (this == &heap) {
return;
}
this->m_obj = heap.m_obj;
this->m_indexStack = heap.m_indexStack;
this->m_allocated = heap.m_allocated;
heap.m_obj = nullptr;
heap.m_indexStack = nullptr;
heap.m_allocated = 0;
}
CObjectHeap::~CObjectHeap() { CObjectHeap::~CObjectHeap() {
this->Free(); this->Free();
} }

View file

@ -6,12 +6,14 @@
class CObjectHeap { class CObjectHeap {
public: public:
// Member variables // Member variables
void* m_obj = nullptr; mutable void* m_obj = nullptr;
uint32_t* m_indexStack = nullptr; mutable uint32_t* m_indexStack = nullptr;
uint32_t m_allocated = 0; mutable uint32_t m_allocated = 0;
// Member functions // Member functions
CObjectHeap() = default; CObjectHeap() = default;
CObjectHeap(const CObjectHeap& heap);
CObjectHeap& operator=(const CObjectHeap& heap) = delete;
~CObjectHeap(); ~CObjectHeap();
int32_t Allocate(uint32_t objSize, uint32_t heapObjects, const char* heapName); int32_t Allocate(uint32_t objSize, uint32_t heapObjects, const char* heapName);