Common/MemArena: A zero-byte allocation is invalid.

This commit is contained in:
Admiral H. Curtiss 2023-09-07 14:41:24 +02:00
parent c14bc6ea4c
commit 422bc7a627
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
3 changed files with 9 additions and 0 deletions

View File

@ -155,6 +155,9 @@ void* LazyMemoryRegion::Create(size_t size)
{
ASSERT(!m_memory);
if (size == 0)
return nullptr;
void* memory = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (memory == MAP_FAILED)
{

View File

@ -121,6 +121,9 @@ void* LazyMemoryRegion::Create(size_t size)
{
ASSERT(!m_memory);
if (size == 0)
return nullptr;
void* memory = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (memory == MAP_FAILED)
{

View File

@ -445,6 +445,9 @@ void* LazyMemoryRegion::Create(size_t size)
{
ASSERT(!m_memory);
if (size == 0)
return nullptr;
void* memory = VirtualAlloc(nullptr, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
if (!memory)
{