To: [email protected]
Subject: patch 7.1b.002
Fcc: outbox
From: Bram Moolenaar <[email protected]>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.1b.002
Problem:    When 'maxmem' is large there can be an overflow in computations.
           (Thomas Wiegner)
Solution:   Use the same mechanism as in mch_total_mem(): first reduce the
           multiplier as much as possible.
Files:      src/memfile.c


*** ../vim-7.1b.001/src/memfile.c       Thu May 10 21:17:23 2007
--- src/memfile.c       Fri May 11 19:50:12 2007
***************
*** 190,196 ****
     mfp->mf_blocknr_min = -1;
     mfp->mf_neg_count = 0;
     mfp->mf_infile_count = mfp->mf_blocknr_max;
!     mfp->mf_used_count_max = p_mm * 1024 / mfp->mf_page_size;

     return mfp;
 }
--- 190,214 ----
     mfp->mf_blocknr_min = -1;
     mfp->mf_neg_count = 0;
     mfp->mf_infile_count = mfp->mf_blocknr_max;
!
!     /*
!      * Compute maximum number of pages ('maxmem' is in Kbyte):
!      *        'mammem' * 1Kbyte / page-size-in-bytes.
!      * Avoid overflow by first reducing page size as much as possible.
!      */
!     {
!       int         shift = 10;
!       unsigned    page_size = mfp->mf_page_size;
!
!       while (shift > 0 && (page_size & 1) == 0)
!       {
!           page_size = page_size >> 1;
!           --shift;
!       }
!       mfp->mf_used_count_max = (p_mm << shift) / page_size;
!       if (mfp->mf_used_count_max < 10)
!           mfp->mf_used_count_max = 10;
!     }

     return mfp;
 }
*** ../vim-7.1b.001/src/version.c       Thu May 10 22:19:40 2007
--- src/version.c       Fri May 11 20:09:22 2007
***************
*** 668,669 ****
--- 668,671 ----
 {   /* Add new patch number below this line */
+ /**/
+     2,
 /**/

--
hundred-and-one symptoms of being an internet addict:
99. The hum of a cooling fan and the click of keys is comforting to you.

/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
\\\            help me help AIDS victims -- http://ICCF-Holland.org    ///