Don't throw in the allocator, return null
This commit is contained in:
parent
4271c8583e
commit
a35e04c049
@ -12,7 +12,6 @@ module tanya.memory.mmappool;
|
|||||||
|
|
||||||
import tanya.memory.allocator;
|
import tanya.memory.allocator;
|
||||||
import core.atomic;
|
import core.atomic;
|
||||||
import core.exception;
|
|
||||||
import core.stdc.string;
|
import core.stdc.string;
|
||||||
|
|
||||||
version (Posix)
|
version (Posix)
|
||||||
@ -334,17 +333,13 @@ final class MmapPool : Allocator
|
|||||||
version (Posix)
|
version (Posix)
|
||||||
{
|
{
|
||||||
void* p = mmap(null,
|
void* p = mmap(null,
|
||||||
regionSize,
|
regionSize,
|
||||||
PROT_READ | PROT_WRITE,
|
PROT_READ | PROT_WRITE,
|
||||||
MAP_PRIVATE | MAP_ANON,
|
MAP_PRIVATE | MAP_ANON,
|
||||||
-1,
|
-1,
|
||||||
0);
|
0);
|
||||||
if (p is MAP_FAILED)
|
if (p is MAP_FAILED)
|
||||||
{
|
{
|
||||||
if (errno == ENOMEM)
|
|
||||||
{
|
|
||||||
onOutOfMemoryError();
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -356,10 +351,6 @@ final class MmapPool : Allocator
|
|||||||
PAGE_READWRITE);
|
PAGE_READWRITE);
|
||||||
if (p is null)
|
if (p is null)
|
||||||
{
|
{
|
||||||
if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY)
|
|
||||||
{
|
|
||||||
onOutOfMemoryError();
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user