mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 21:34:08 -07:00
h_mgr: compile fix for windows memory tracker (see forum thread) timer: add assert to catch incorrect behaviour as reported by philip This was SVN commit r5544.
41 lines
681 B
C++
41 lines
681 B
C++
#ifndef INCLUDED_SHARED_PTR
|
|
#define INCLUDED_SHARED_PTR
|
|
|
|
// adapter that allows calling page_aligned_free as a shared_ptr deleter.
|
|
class PageAlignedDeleter
|
|
{
|
|
public:
|
|
PageAlignedDeleter(size_t size);
|
|
void operator()(u8* p);
|
|
|
|
private:
|
|
size_t m_size;
|
|
};
|
|
|
|
struct DummyDeleter
|
|
{
|
|
template<class T>
|
|
void operator()(T*)
|
|
{
|
|
}
|
|
};
|
|
|
|
template<class T>
|
|
shared_ptr<T> DummySharedPtr(T* ptr)
|
|
{
|
|
return shared_ptr<T>(ptr, DummyDeleter());
|
|
}
|
|
|
|
struct ArrayDeleter
|
|
{
|
|
template<class T>
|
|
void operator()(T* p)
|
|
{
|
|
delete[] p;
|
|
}
|
|
};
|
|
|
|
// (note: uses CheckedArrayDeleter)
|
|
LIB_API shared_ptr<u8> Allocate(size_t size);
|
|
|
|
#endif // #ifndef INCLUDED_SHARED_PTR
|