]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
updated for version 7.3.577 v7.3.577
authorBram Moolenaar <Bram@vim.org>
Fri, 29 Jun 2012 13:51:30 +0000 (15:51 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 29 Jun 2012 13:51:30 +0000 (15:51 +0200)
Problem:    Size of memory does not fit in 32 bit unsigned.
Solution:   Use Kbyte instead of byte.  Call GlobalMemoryStatusEx() instead of
            GlobalMemoryStatus() when available.

src/misc2.c
src/option.c
src/os_amiga.c
src/os_msdos.c
src/os_win16.c
src/os_win32.c
src/version.c

index d62c771cddd0d786cdfa2a39404b44e9903b39dc..5d60954be5a73ec776ce28bd2b63d0c6211c8c81 100644 (file)
@@ -815,6 +815,7 @@ vim_mem_profile_dump()
 #else
 # define KEEP_ROOM (2 * 8192L)
 #endif
+#define KEEP_ROOM_KB (KEEP_ROOM / 1024L)
 
 /*
  * Note: if unsigned is 16 bits we can only allocate up to 64K with alloc().
@@ -940,7 +941,7 @@ lalloc(size, message)
            allocated = 0;
 # endif
            /* 3. check for available memory: call mch_avail_mem() */
-           if (mch_avail_mem(TRUE) < KEEP_ROOM && !releasing)
+           if (mch_avail_mem(TRUE) < KEEP_ROOM_KB && !releasing)
            {
                free((char *)p);        /* System is low... no go! */
                p = NULL;
index 9acb270f1e05e864bb092aa254cb24d9d4a8ed13..308d7a81fbab9cf2e86cba90708459d645642c34 100644 (file)
@@ -3154,7 +3154,7 @@ set_init_1()
        {
 #ifdef HAVE_AVAIL_MEM
            /* Use amount of memory available at this moment. */
-           n = (mch_avail_mem(FALSE) >> 11);
+           n = (mch_avail_mem(FALSE) >> 1);
 #else
 # ifdef HAVE_TOTAL_MEM
            /* Use amount of memory available to Vim. */
@@ -6702,7 +6702,7 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
     {
        for (s = *varp; *s;)
        {
-           while(*s == ',' || *s == ' ')
+           while (*s == ',' || *s == ' ')
                s++;
            if (!*s)
                break;
@@ -7391,7 +7391,7 @@ check_clipboard_option()
            new_unnamed |= CLIP_UNNAMED;
            p += 7;
        }
-        else if (STRNCMP(p, "unnamedplus", 11) == 0
+       else if (STRNCMP(p, "unnamedplus", 11) == 0
                                            && (p[11] == ',' || p[11] == NUL))
        {
            new_unnamed |= CLIP_UNNAMED_PLUS;
index d84af4ce16bf033bafcc53eecff7bbd5e8a20d98..e2b15794997073c4b47a02cd9d5657986574e669 100644 (file)
@@ -191,16 +191,16 @@ mch_char_avail()
 }
 
 /*
- * Return amount of memory still available.
+ * Return amount of memory still available in Kbyte.
  */
     long_u
 mch_avail_mem(special)
     int            special;
 {
 #ifdef __amigaos4__
-    return (long_u)AvailMem(MEMF_ANY);
+    return (long_u)AvailMem(MEMF_ANY) >> 10;
 #else
-    return (long_u)AvailMem(special ? (long)MEMF_CHIP : (long)MEMF_ANY);
+    return (long_u)(AvailMem(special ? (long)MEMF_CHIP : (long)MEMF_ANY)) >> 10;
 #endif
 }
 
index 3449d23b9b5cd4ca6aba819fec57cb7713613764..2d1cf73ddcc6672ddb16329c4d901c0c1b2af44d 100644 (file)
@@ -550,15 +550,15 @@ mch_update_cursor(void)
 #endif
 
 /*
- * Return amount of memory currently available.
+ * Return amount of memory currently available in Kbyte.
  */
     long_u
 mch_avail_mem(int special)
 {
 #ifdef DJGPP
-    return _go32_dpmi_remaining_virtual_memory();
+    return _go32_dpmi_remaining_virtual_memory() >> 10;
 #else
-    return coreleft();
+    return coreleft() >> 10;
 #endif
 }
 
index 0be6c6316a33fd1549bae5f227f1bda98d6bb8c3..b620149e792be460a8b6428f0aa4922a89686788 100644 (file)
@@ -379,13 +379,13 @@ mch_breakcheck()
 
 
 /*
- * How much memory is available?
+ * How much memory is available in Kbyte?
  */
     long_u
 mch_avail_mem(
     int special)
 {
-    return GetFreeSpace(0);
+    return GetFreeSpace(0) >> 10;
 }
 
 
index c0434dbda4d375577c8e482cc748dc2d767576d4..af1232eaba18acc79e612cf61d98495b72aed95c 100644 (file)
@@ -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;
+    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(MEMORYSTATUS);
-    GlobalMemoryStatus(&ms);
-    return (long_u) (ms.dwAvailPhys + ms.dwAvailPageFile);
+       ms.dwLength = sizeof(MEMORYSTATUSEX);
+       GlobalMemoryStatusEx(&ms);
+       return (long_u)((ms.ullAvailPhys + ms.ullAvailPageFile) >> 10);
+    }
 }
 
 #ifdef FEAT_MBYTE
index 646d223bd002e8f473aa9e175c02731c72966037..58bb4732c00c4b6621cff8a1a9c616fe73bc8310 100644 (file)
@@ -714,6 +714,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    577,
 /**/
     576,
 /**/