mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 14:03:17 +02:00
Fix catching bad_alloc
Non-allocation wasn't caught on Windows; it just crashed.
This commit is contained in:
parent
5e681ee56b
commit
e768852645
1 changed files with 4 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue