prime/include/Kyoto/TOneStatic.hpp
Luke Street 7ca3a1c0bb Replace int types in Retro code
Retro seemingly avoided using the Dolphin
typedefs in most places, opting to use int/uint
instead. This likely means they didn't use
u8/s8/u16/s16/etc either.


Former-commit-id: 133326ae406a0ebc76f56f8bcb489fda280be2be
2022-10-09 01:37:23 -04:00

33 lines
702 B
C++

#ifndef _TONESTATIC
#define _TONESTATIC
#include "types.h"
template < typename T >
class TOneStatic {
public:
void* operator new(unsigned long sz, const char*, const char*); /* {
ReferenceCount()++;
return GetAllocSpace();
}*/
void* operator new(unsigned long sz) { return operator new(sz, "??(??)", nullptr); }
void operator delete(void* ptr);
private:
static void* GetAllocSpace() {
static uchar sAllocSpace[sizeof(T)];
return &sAllocSpace;
}
static uint& ReferenceCount() {
static uint sReferenceCount = 0;
return sReferenceCount;
}
};
template < typename T >
void TOneStatic< T >::operator delete(void* ptr) {
ReferenceCount()--;
}
#endif // _TONESTATIC