updated for version 7.3.577
Problem: Size of memory does not fit in 32 bit unsigned.
Solution: Use Kbyte instead of byte. Call GlobalMemoryStatusEx() instead of
GlobalMemoryStatus() when available.
diff --git a/src/os_win32.c b/src/os_win32.c
index c0434db..af1232e 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -4992,18 +4992,29 @@
/*
- * How much memory is available?
+ * How much memory is available in Kbyte?
* Return sum of available physical and page file memory.
*/
/*ARGSUSED*/
long_u
mch_avail_mem(int special)
{
- MEMORYSTATUS ms;
+ if (g_PlatformId != VER_PLATFORM_WIN32_NT)
+ {
+ MEMORYSTATUS ms;
- ms.dwLength = sizeof(MEMORYSTATUS);
- GlobalMemoryStatus(&ms);
- return (long_u) (ms.dwAvailPhys + ms.dwAvailPageFile);
+ ms.dwLength = sizeof(MEMORYSTATUS);
+ GlobalMemoryStatus(&ms);
+ return (long_u)((ms.dwAvailPhys + ms.dwAvailPageFile) >> 10);
+ }
+ else
+ {
+ MEMORYSTATUSEX ms;
+
+ ms.dwLength = sizeof(MEMORYSTATUSEX);
+ GlobalMemoryStatusEx(&ms);
+ return (long_u)((ms.ullAvailPhys + ms.ullAvailPageFile) >> 10);
+ }
}
#ifdef FEAT_MBYTE