0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

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.
This commit is contained in:
Bram Moolenaar
2012-06-29 15:51:30 +02:00
parent 96b7ca5142
commit 11b73d668f
7 changed files with 31 additions and 17 deletions

View 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;

View 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;

View 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
}

View 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
}

View 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;
}

View 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);
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

View File

@@ -714,6 +714,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
577,
/**/
576,
/**/