]> granicus.if.org Git - vim/commitdiff
updated for version 7.1b-002 v7.1b.002
authorBram Moolenaar <Bram@vim.org>
Fri, 11 May 2007 18:15:45 +0000 (18:15 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 11 May 2007 18:15:45 +0000 (18:15 +0000)
src/memfile.c
src/version.c

index f1e85fc281c9038bafec41a9ba24450c27c6c7c1..d0dd8deef3fb2aa6d621642a9db1bf5f78d6a06e 100644 (file)
@@ -190,7 +190,25 @@ mf_open(fname, flags)
     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;
+
+    /*
+     * 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;
 }
index c0f9b4b693c930958ec4662b5cf2e22eb3424cf1..17966651f2432552ce058e325c74d9787c4da3c4 100644 (file)
@@ -666,6 +666,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2,
 /**/
     1,
 /**/