]> git.eshelyaron.com Git - emacs.git/commitdiff
(mmap_enlarge): Don't return 0 if successful.
authorGerd Moellmann <gerd@gnu.org>
Sun, 10 Sep 2000 11:19:00 +0000 (11:19 +0000)
committerGerd Moellmann <gerd@gnu.org>
Sun, 10 Sep 2000 11:19:00 +0000 (11:19 +0000)
src/ChangeLog
src/ralloc.c

index 3a175418f4a78bc4c4c67d1afb573de008a2cde8..3d00ebfeba2756f63e7d2cd6137a703cd40c829f 100644 (file)
@@ -1,3 +1,7 @@
+2000-09-10  Gerd Moellmann  <gerd@gnu.org>
+
+       * ralloc.c (mmap_enlarge): Don't return 0 if successful.
+
 2000-09-09  Ken Raeburn  <raeburn@gnu.org>
 
        * s/netbsd.h: Use NOT_C_CODE, not NO_C_SOURCE, when deciding
@@ -6,7 +10,7 @@
 2000-09-09  Gerd Moellmann  <gerd@gnu.org>
 
        * xfaces.c (CYCLE_CHECK): Don't use the Lisp_Object returned 
-       by Fmemq in a condition.
+       by Fmemq as a boolean.
 
 2000-09-08  Stefan Monnier  <monnier@cs.yale.edu>
 
index a90b651479943151027e0edef9df8911eecb9a0b..9858e45a87e50916cca05bc5d8ddbdeb18fe5c8c 100644 (file)
@@ -1389,41 +1389,39 @@ mmap_enlarge (r, npages)
 {
   char *region_end = (char *) r + r->nbytes_mapped;
   size_t nbytes;
-  int success = 1;
+  int success = 0;
 
   if (npages < 0)
     {
       /* Unmap pages at the end of the region.  */
       nbytes = - npages * page_size;
       if (munmap (region_end - nbytes, nbytes) == -1)
+       fprintf (stderr, "munmap: %s\n", emacs_strerror (errno));
+      else
        {
-         fprintf (stderr, "munmap: %s\n", emacs_strerror (errno));
-         success = 0;
+         r->nbytes_mapped -= nbytes;
+         success = 1;
        }
-      else
-       r->nbytes_mapped -= nbytes;
     }
   else if (npages > 0)
     {
+      struct mmap_region *r2;
+      
       nbytes = npages * page_size;
       
       /* Try to map additional pages at the end of the region.  We
         cannot do this if the address range is already occupied by
         something else because mmap deletes any previous mapping.
         I'm not sure this is worth doing, let's see.  */
-      if (mmap_find (region_end, region_end + nbytes))
-       success = 0;
-      else
+      r2 = mmap_find (region_end, region_end + nbytes);
+      if (r2 == NULL)
        {
          POINTER_TYPE *p;
       
          p = mmap (region_end, nbytes, PROT_READ | PROT_WRITE,
                    MAP_ANON | MAP_PRIVATE | MAP_FIXED, mmap_fd, 0);
          if (p == MAP_FAILED)
-           {
-             fprintf (stderr, "mmap: %s\n", emacs_strerror (errno));
-             success = 0;
-           }
+           fprintf (stderr, "mmap: %s\n", emacs_strerror (errno));
          else if (p != (POINTER_TYPE *) region_end)
            {
              /* Kernels are free to choose a different address.  In
@@ -1431,13 +1429,13 @@ mmap_enlarge (r, npages)
                 no use for it.  */
              if (munmap (p, nbytes) == -1)
                fprintf (stderr, "munmap: %s\n", emacs_strerror (errno));
-             success = 0;
            }
          else
-           r->nbytes_mapped += nbytes;
+           {
+             r->nbytes_mapped += nbytes;
+             success = 1;
+           }
        }
-      
-      success = 0;
     }
 
   return success;