Add better error message on VirtualAlloc failure on windows.

This commit is contained in:
Christoffer Lerno
2026-01-23 11:45:00 +01:00
parent 459969ddb2
commit efa5bdc6df

View File

@@ -65,7 +65,11 @@ static inline void* mmap_allocate(Vmem *vmem, size_t to_allocate)
{ {
size_t to_commit = blocks_to_allocate * COMMIT_PAGE_SIZE; size_t to_commit = blocks_to_allocate * COMMIT_PAGE_SIZE;
void *res = VirtualAlloc(((char*)vmem->ptr) + vmem->committed, to_commit, MEM_COMMIT, PAGE_READWRITE); void *res = VirtualAlloc(((char*)vmem->ptr) + vmem->committed, to_commit, MEM_COMMIT, PAGE_READWRITE);
if (!res) FATAL_ERROR("Failed to allocate more memory."); if (!res)
{
error_exit("Fatal Error! The compiler ran out of memory: more than %u MB was allocated from a single memory arena, "
"which was rejected. Perhaps you called some recursive macro?", (unsigned)(allocated_after / (1024 * 1024)));
}
vmem->committed += to_commit; vmem->committed += to_commit;
} }
#endif #endif