Mercurial > vim
diff src/os_win32.c @ 3634:286ba0251c0a v7.3.577
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.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Fri, 29 Jun 2012 15:51:30 +0200 |
parents | 43fd3896fab7 |
children | 4873d9c4ad3b |
line wrap: on
line diff
--- a/src/os_win32.c +++ b/src/os_win32.c @@ -4992,18 +4992,29 @@ mch_breakcheck(void) /* - * 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; - - ms.dwLength = sizeof(MEMORYSTATUS); - GlobalMemoryStatus(&ms); - return (long_u) (ms.dwAvailPhys + ms.dwAvailPageFile); + if (g_PlatformId != VER_PLATFORM_WIN32_NT) + { + MEMORYSTATUS ms; + + 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