Merge pull request #4624 from ctrlaltdavid/memory-fixes

Replace try with nothrow
This commit is contained in:
Brad Davis 2015-04-09 12:30:44 -07:00
commit 3d6cf82659

View file

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