Fix catching bad_alloc

Non-allocation wasn't caught on Windows; it just crashed.
This commit is contained in:
David Rowe 2015-04-08 20:02:22 -07:00
parent 5e681ee56b
commit e768852645

View file

@ -27,9 +27,10 @@ Resource::Size Resource::Sysmem::allocateMemory(Byte** dataAllocated, Size size)
if (size > 0) {
// Try allocating as much as the required size + one block of memory
newSize = size;
(*dataAllocated) = new Byte[newSize];
// Failed?
if (!(*dataAllocated)) {
try {
(*dataAllocated) = new Byte[newSize];
}
catch (const std::bad_alloc&) {
qWarning() << "Buffer::Sysmem::allocate() : Can't allocate a system memory buffer of " << newSize << "bytes. Fails to create the buffer Sysmem.";
return NOT_ALLOCATED;
}