mirror of
https://github.com/thunderbrewhq/common.git
synced 2025-12-12 03:02:29 +00:00
feat(objectalloc): implement copy constructor for CObjectHeap
This commit is contained in:
parent
199a2c46cb
commit
5d0182796e
2 changed files with 17 additions and 3 deletions
|
|
@ -4,6 +4,18 @@
|
|||
#include <bc/Memory.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() {
|
||||
this->Free();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@
|
|||
class CObjectHeap {
|
||||
public:
|
||||
// Member variables
|
||||
void* m_obj = nullptr;
|
||||
uint32_t* m_indexStack = nullptr;
|
||||
uint32_t m_allocated = 0;
|
||||
mutable void* m_obj = nullptr;
|
||||
mutable uint32_t* m_indexStack = nullptr;
|
||||
mutable uint32_t m_allocated = 0;
|
||||
|
||||
// Member functions
|
||||
CObjectHeap() = default;
|
||||
CObjectHeap(const CObjectHeap& heap);
|
||||
CObjectHeap& operator=(const CObjectHeap& heap) = delete;
|
||||
~CObjectHeap();
|
||||
|
||||
int32_t Allocate(uint32_t objSize, uint32_t heapObjects, const char* heapName);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue