Karsten Hopp 275da1
To: vim_dev@googlegroups.com
Karsten Hopp 275da1
Subject: Patch 7.3.577
Karsten Hopp 275da1
Fcc: outbox
Karsten Hopp 275da1
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 275da1
Mime-Version: 1.0
Karsten Hopp 275da1
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 275da1
Content-Transfer-Encoding: 8bit
Karsten Hopp 275da1
------------
Karsten Hopp 275da1
Karsten Hopp 275da1
Patch 7.3.577
Karsten Hopp 275da1
Problem:    Size of memory does not fit in 32 bit unsigned.
Karsten Hopp 275da1
Solution:   Use Kbyte instead of byte.  Call GlobalMemoryStatusEx() instead of
Karsten Hopp 275da1
	    GlobalMemoryStatus() when available.
Karsten Hopp 275da1
Files:	    src/misc2.c, src/option.c, src/os_amiga.c, src/os_msdos.c,
Karsten Hopp 275da1
	    src/os_win16.c, src/os_win32.c
Karsten Hopp 275da1
Karsten Hopp 275da1
Karsten Hopp 275da1
*** ../vim-7.3.576/src/misc2.c	2012-02-29 13:58:43.000000000 +0100
Karsten Hopp 275da1
--- src/misc2.c	2012-06-29 15:30:54.000000000 +0200
Karsten Hopp 275da1
***************
Karsten Hopp 275da1
*** 815,820 ****
Karsten Hopp 275da1
--- 815,821 ----
Karsten Hopp 275da1
  #else
Karsten Hopp 275da1
  # define KEEP_ROOM (2 * 8192L)
Karsten Hopp 275da1
  #endif
Karsten Hopp 275da1
+ #define KEEP_ROOM_KB (KEEP_ROOM / 1024L)
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  /*
Karsten Hopp 275da1
   * Note: if unsigned is 16 bits we can only allocate up to 64K with alloc().
Karsten Hopp 275da1
***************
Karsten Hopp 275da1
*** 940,946 ****
Karsten Hopp 275da1
  	    allocated = 0;
Karsten Hopp 275da1
  # endif
Karsten Hopp 275da1
  	    /* 3. check for available memory: call mch_avail_mem() */
Karsten Hopp 275da1
! 	    if (mch_avail_mem(TRUE) < KEEP_ROOM && !releasing)
Karsten Hopp 275da1
  	    {
Karsten Hopp 275da1
  		free((char *)p);	/* System is low... no go! */
Karsten Hopp 275da1
  		p = NULL;
Karsten Hopp 275da1
--- 941,947 ----
Karsten Hopp 275da1
  	    allocated = 0;
Karsten Hopp 275da1
  # endif
Karsten Hopp 275da1
  	    /* 3. check for available memory: call mch_avail_mem() */
Karsten Hopp 275da1
! 	    if (mch_avail_mem(TRUE) < KEEP_ROOM_KB && !releasing)
Karsten Hopp 275da1
  	    {
Karsten Hopp 275da1
  		free((char *)p);	/* System is low... no go! */
Karsten Hopp 275da1
  		p = NULL;
Karsten Hopp 275da1
*** ../vim-7.3.576/src/option.c	2012-03-28 19:58:34.000000000 +0200
Karsten Hopp 275da1
--- src/option.c	2012-06-29 15:31:46.000000000 +0200
Karsten Hopp 275da1
***************
Karsten Hopp 275da1
*** 3154,3160 ****
Karsten Hopp 275da1
  	{
Karsten Hopp 275da1
  #ifdef HAVE_AVAIL_MEM
Karsten Hopp 275da1
  	    /* Use amount of memory available at this moment. */
Karsten Hopp 275da1
! 	    n = (mch_avail_mem(FALSE) >> 11);
Karsten Hopp 275da1
  #else
Karsten Hopp 275da1
  # ifdef HAVE_TOTAL_MEM
Karsten Hopp 275da1
  	    /* Use amount of memory available to Vim. */
Karsten Hopp 275da1
--- 3154,3160 ----
Karsten Hopp 275da1
  	{
Karsten Hopp 275da1
  #ifdef HAVE_AVAIL_MEM
Karsten Hopp 275da1
  	    /* Use amount of memory available at this moment. */
Karsten Hopp 275da1
! 	    n = (mch_avail_mem(FALSE) >> 1);
Karsten Hopp 275da1
  #else
Karsten Hopp 275da1
  # ifdef HAVE_TOTAL_MEM
Karsten Hopp 275da1
  	    /* Use amount of memory available to Vim. */
Karsten Hopp 275da1
***************
Karsten Hopp 275da1
*** 6702,6708 ****
Karsten Hopp 275da1
      {
Karsten Hopp 275da1
  	for (s = *varp; *s;)
Karsten Hopp 275da1
  	{
Karsten Hopp 275da1
! 	    while(*s == ',' || *s == ' ')
Karsten Hopp 275da1
  		s++;
Karsten Hopp 275da1
  	    if (!*s)
Karsten Hopp 275da1
  		break;
Karsten Hopp 275da1
--- 6702,6708 ----
Karsten Hopp 275da1
      {
Karsten Hopp 275da1
  	for (s = *varp; *s;)
Karsten Hopp 275da1
  	{
Karsten Hopp 275da1
! 	    while (*s == ',' || *s == ' ')
Karsten Hopp 275da1
  		s++;
Karsten Hopp 275da1
  	    if (!*s)
Karsten Hopp 275da1
  		break;
Karsten Hopp 275da1
***************
Karsten Hopp 275da1
*** 7391,7397 ****
Karsten Hopp 275da1
  	    new_unnamed |= CLIP_UNNAMED;
Karsten Hopp 275da1
  	    p += 7;
Karsten Hopp 275da1
  	}
Karsten Hopp 275da1
!         else if (STRNCMP(p, "unnamedplus", 11) == 0
Karsten Hopp 275da1
  					    && (p[11] == ',' || p[11] == NUL))
Karsten Hopp 275da1
  	{
Karsten Hopp 275da1
  	    new_unnamed |= CLIP_UNNAMED_PLUS;
Karsten Hopp 275da1
--- 7391,7397 ----
Karsten Hopp 275da1
  	    new_unnamed |= CLIP_UNNAMED;
Karsten Hopp 275da1
  	    p += 7;
Karsten Hopp 275da1
  	}
Karsten Hopp 275da1
! 	else if (STRNCMP(p, "unnamedplus", 11) == 0
Karsten Hopp 275da1
  					    && (p[11] == ',' || p[11] == NUL))
Karsten Hopp 275da1
  	{
Karsten Hopp 275da1
  	    new_unnamed |= CLIP_UNNAMED_PLUS;
Karsten Hopp 275da1
*** ../vim-7.3.576/src/os_amiga.c	2011-10-20 18:24:16.000000000 +0200
Karsten Hopp 275da1
--- src/os_amiga.c	2012-06-29 15:33:59.000000000 +0200
Karsten Hopp 275da1
***************
Karsten Hopp 275da1
*** 191,206 ****
Karsten Hopp 275da1
  }
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  /*
Karsten Hopp 275da1
!  * Return amount of memory still available.
Karsten Hopp 275da1
   */
Karsten Hopp 275da1
      long_u
Karsten Hopp 275da1
  mch_avail_mem(special)
Karsten Hopp 275da1
      int	    special;
Karsten Hopp 275da1
  {
Karsten Hopp 275da1
  #ifdef __amigaos4__
Karsten Hopp 275da1
!     return (long_u)AvailMem(MEMF_ANY);
Karsten Hopp 275da1
  #else
Karsten Hopp 275da1
!     return (long_u)AvailMem(special ? (long)MEMF_CHIP : (long)MEMF_ANY);
Karsten Hopp 275da1
  #endif
Karsten Hopp 275da1
  }
Karsten Hopp 275da1
  
Karsten Hopp 275da1
--- 191,206 ----
Karsten Hopp 275da1
  }
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  /*
Karsten Hopp 275da1
!  * Return amount of memory still available in Kbyte.
Karsten Hopp 275da1
   */
Karsten Hopp 275da1
      long_u
Karsten Hopp 275da1
  mch_avail_mem(special)
Karsten Hopp 275da1
      int	    special;
Karsten Hopp 275da1
  {
Karsten Hopp 275da1
  #ifdef __amigaos4__
Karsten Hopp 275da1
!     return (long_u)AvailMem(MEMF_ANY) >> 10;
Karsten Hopp 275da1
  #else
Karsten Hopp 275da1
!     return (long_u)(AvailMem(special ? (long)MEMF_CHIP : (long)MEMF_ANY)) >> 10;
Karsten Hopp 275da1
  #endif
Karsten Hopp 275da1
  }
Karsten Hopp 275da1
  
Karsten Hopp 275da1
*** ../vim-7.3.576/src/os_msdos.c	2011-06-19 01:14:22.000000000 +0200
Karsten Hopp 275da1
--- src/os_msdos.c	2012-06-29 15:33:26.000000000 +0200
Karsten Hopp 275da1
***************
Karsten Hopp 275da1
*** 550,564 ****
Karsten Hopp 275da1
  #endif
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  /*
Karsten Hopp 275da1
!  * Return amount of memory currently available.
Karsten Hopp 275da1
   */
Karsten Hopp 275da1
      long_u
Karsten Hopp 275da1
  mch_avail_mem(int special)
Karsten Hopp 275da1
  {
Karsten Hopp 275da1
  #ifdef DJGPP
Karsten Hopp 275da1
!     return _go32_dpmi_remaining_virtual_memory();
Karsten Hopp 275da1
  #else
Karsten Hopp 275da1
!     return coreleft();
Karsten Hopp 275da1
  #endif
Karsten Hopp 275da1
  }
Karsten Hopp 275da1
  
Karsten Hopp 275da1
--- 550,564 ----
Karsten Hopp 275da1
  #endif
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  /*
Karsten Hopp 275da1
!  * Return amount of memory currently available in Kbyte.
Karsten Hopp 275da1
   */
Karsten Hopp 275da1
      long_u
Karsten Hopp 275da1
  mch_avail_mem(int special)
Karsten Hopp 275da1
  {
Karsten Hopp 275da1
  #ifdef DJGPP
Karsten Hopp 275da1
!     return _go32_dpmi_remaining_virtual_memory() >> 10;
Karsten Hopp 275da1
  #else
Karsten Hopp 275da1
!     return coreleft() >> 10;
Karsten Hopp 275da1
  #endif
Karsten Hopp 275da1
  }
Karsten Hopp 275da1
  
Karsten Hopp 275da1
*** ../vim-7.3.576/src/os_win16.c	2011-10-20 18:24:16.000000000 +0200
Karsten Hopp 275da1
--- src/os_win16.c	2012-06-29 15:34:18.000000000 +0200
Karsten Hopp 275da1
***************
Karsten Hopp 275da1
*** 379,391 ****
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  /*
Karsten Hopp 275da1
!  * How much memory is available?
Karsten Hopp 275da1
   */
Karsten Hopp 275da1
      long_u
Karsten Hopp 275da1
  mch_avail_mem(
Karsten Hopp 275da1
      int special)
Karsten Hopp 275da1
  {
Karsten Hopp 275da1
!     return GetFreeSpace(0);
Karsten Hopp 275da1
  }
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  
Karsten Hopp 275da1
--- 379,391 ----
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  /*
Karsten Hopp 275da1
!  * How much memory is available in Kbyte?
Karsten Hopp 275da1
   */
Karsten Hopp 275da1
      long_u
Karsten Hopp 275da1
  mch_avail_mem(
Karsten Hopp 275da1
      int special)
Karsten Hopp 275da1
  {
Karsten Hopp 275da1
!     return GetFreeSpace(0) >> 10;
Karsten Hopp 275da1
  }
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  
Karsten Hopp 275da1
*** ../vim-7.3.576/src/os_win32.c	2012-06-29 13:13:59.000000000 +0200
Karsten Hopp 275da1
--- src/os_win32.c	2012-06-29 15:39:52.000000000 +0200
Karsten Hopp 275da1
***************
Karsten Hopp 275da1
*** 4992,5009 ****
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  /*
Karsten Hopp 275da1
!  * How much memory is available?
Karsten Hopp 275da1
   * Return sum of available physical and page file memory.
Karsten Hopp 275da1
   */
Karsten Hopp 275da1
  /*ARGSUSED*/
Karsten Hopp 275da1
      long_u
Karsten Hopp 275da1
  mch_avail_mem(int special)
Karsten Hopp 275da1
  {
Karsten Hopp 275da1
!     MEMORYSTATUS	ms;
Karsten Hopp 275da1
  
Karsten Hopp 275da1
!     ms.dwLength = sizeof(MEMORYSTATUS);
Karsten Hopp 275da1
!     GlobalMemoryStatus(&ms);
Karsten Hopp 275da1
!     return (long_u) (ms.dwAvailPhys + ms.dwAvailPageFile);
Karsten Hopp 275da1
  }
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  #ifdef FEAT_MBYTE
Karsten Hopp 275da1
--- 4992,5020 ----
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  /*
Karsten Hopp 275da1
!  * How much memory is available in Kbyte?
Karsten Hopp 275da1
   * Return sum of available physical and page file memory.
Karsten Hopp 275da1
   */
Karsten Hopp 275da1
  /*ARGSUSED*/
Karsten Hopp 275da1
      long_u
Karsten Hopp 275da1
  mch_avail_mem(int special)
Karsten Hopp 275da1
  {
Karsten Hopp 275da1
!     if (g_PlatformId != VER_PLATFORM_WIN32_NT)
Karsten Hopp 275da1
!     {
Karsten Hopp 275da1
! 	MEMORYSTATUS	ms;
Karsten Hopp 275da1
  
Karsten Hopp 275da1
! 	ms.dwLength = sizeof(MEMORYSTATUS);
Karsten Hopp 275da1
! 	GlobalMemoryStatus(&ms);
Karsten Hopp 275da1
! 	return (long_u)((ms.dwAvailPhys + ms.dwAvailPageFile) >> 10);
Karsten Hopp 275da1
!     }
Karsten Hopp 275da1
!     else
Karsten Hopp 275da1
!     {
Karsten Hopp 275da1
! 	MEMORYSTATUSEX	ms;
Karsten Hopp 275da1
! 
Karsten Hopp 275da1
! 	ms.dwLength = sizeof(MEMORYSTATUSEX);
Karsten Hopp 275da1
! 	GlobalMemoryStatusEx(&ms);
Karsten Hopp 275da1
! 	return (long_u)((ms.ullAvailPhys + ms.ullAvailPageFile) >> 10);
Karsten Hopp 275da1
!     }
Karsten Hopp 275da1
  }
Karsten Hopp 275da1
  
Karsten Hopp 275da1
  #ifdef FEAT_MBYTE
Karsten Hopp 275da1
*** ../vim-7.3.576/src/version.c	2012-06-29 15:04:34.000000000 +0200
Karsten Hopp 275da1
--- src/version.c	2012-06-29 15:45:44.000000000 +0200
Karsten Hopp 275da1
***************
Karsten Hopp 275da1
*** 716,717 ****
Karsten Hopp 275da1
--- 716,719 ----
Karsten Hopp 275da1
  {   /* Add new patch number below this line */
Karsten Hopp 275da1
+ /**/
Karsten Hopp 275da1
+     577,
Karsten Hopp 275da1
  /**/
Karsten Hopp 275da1
Karsten Hopp 275da1
-- 
Karsten Hopp 275da1
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 275da1
75. You start wondering whether you could actually upgrade your brain
Karsten Hopp 275da1
    with a Pentium Pro microprocessor 80.  The upgrade works just fine.
Karsten Hopp 275da1
Karsten Hopp 275da1
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 275da1
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 275da1
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 275da1
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///