Created
May 9, 2017 21:13
-
-
Save BillyONeal/cb07926e01c60202ea7342b91f8c6487 to your computer and use it in GitHub Desktop.
OVR Allocator Patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <class T> | |
class StdAllocatorSysMem | |
{ | |
public: | |
typedef T value_type; | |
StdAllocatorSysMem() = default; | |
StdAllocatorSysMem(const StdAllocatorSysMem&) = default; | |
template <class Other> | |
StdAllocatorSysMem(const StdAllocatorSysMem<Other>&) | |
{ | |
} | |
void deallocate(T * p, size_t n) const | |
{ | |
if(p) | |
SysMemFree(p, n); | |
} | |
T * allocate(size_t n) const | |
{ | |
void* pVoid = SysMemAlloc(n * sizeof(T)); | |
if(!pVoid) | |
throw ::std::bad_alloc(); | |
return static_cast<T *>(pVoid); | |
} | |
}; | |
template <class T, class U> | |
bool operator==(const StdAllocatorSysMem<T>&, const StdAllocatorSysMem<U>&) | |
{ | |
return true; | |
} | |
template <class T, class U> | |
bool operator!=(const StdAllocatorSysMem<T>&, const StdAllocatorSysMem<U>&) | |
{ | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment