From 67ee1e4d767ef45738dd869c2df8236e16de4474 Mon Sep 17 00:00:00 2001 From: Miku AuahDark Date: Tue, 28 Jan 2020 21:25:58 +0800 Subject: [PATCH] Windows: Actually query page size. --- src/common/memory.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/common/memory.cpp b/src/common/memory.cpp index 1ed4f8eae..6907acd02 100644 --- a/src/common/memory.cpp +++ b/src/common/memory.cpp @@ -24,7 +24,9 @@ #include #ifdef LOVE_WINDOWS +#define WIN32_LEAN_AND_MEAN #include +#include #else #include // Assume POSIX support. #endif @@ -54,8 +56,15 @@ void alignedFree(void *mem) size_t getPageSize() { #ifdef LOVE_WINDOWS - // TODO: Do an actual query. - return 4096; + static DWORD size = 0; + if (size == 0) + { + SYSTEM_INFO si; + GetSystemInfo(&si); + size = si.dwPageSize; + } + + return (size_t) size; #else static const long size = sysconf(_SC_PAGESIZE); return size > 0 ? (size_t) size : 4096;