Skip to content

Instantly share code, notes, and snippets.

@BillyONeal
Created May 9, 2017 21:13
Show Gist options
  • Save BillyONeal/cb07926e01c60202ea7342b91f8c6487 to your computer and use it in GitHub Desktop.
Save BillyONeal/cb07926e01c60202ea7342b91f8c6487 to your computer and use it in GitHub Desktop.
OVR Allocator Patch
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