mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-07 11:27:26 -04:00
038ef4216f
Fixes #25 This isolates the JKRHeap operator new/delete overloads. Every single new/delete site in the code has been replaced with a macro. Sadly for new[] and delete[] we have to keep global operators. The global new[] just allocates into malloc() however, and delete[] goes into free() if it's not in a JKRHeap. So that's fine.
36 lines
581 B
C++
36 lines
581 B
C++
#ifndef POINTER_H
|
|
#define POINTER_H
|
|
|
|
#include "JSystem/JKernel/JKRHeap.h"
|
|
|
|
namespace JGadget {
|
|
|
|
template<class T>
|
|
class TPointer {
|
|
public:
|
|
TPointer(T* ptr) : mPtr(ptr) {}
|
|
~TPointer() {}
|
|
void set(T* ptr) { mPtr = ptr; }
|
|
T* mPtr;
|
|
};
|
|
|
|
template<class T>
|
|
class TPointer_delete : public TPointer<T> {
|
|
public:
|
|
#ifdef __MWERKS__
|
|
TPointer_delete(T* ptr) : TPointer(ptr) {}
|
|
~TPointer_delete() {
|
|
JKR_DELETE(mPtr);
|
|
}
|
|
#else
|
|
TPointer_delete(T* ptr) : TPointer<T>(ptr) {}
|
|
~TPointer_delete() {
|
|
JKR_DELETE(this->mPtr);
|
|
}
|
|
#endif
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|