]> git.eshelyaron.com Git - emacs.git/commitdiff
Minor improvement of sbrk emulation on MS-Windows.
authorEli Zaretskii <eliz@gnu.org>
Mon, 2 Jun 2014 17:08:50 +0000 (20:08 +0300)
committerEli Zaretskii <eliz@gnu.org>
Mon, 2 Jun 2014 17:08:50 +0000 (20:08 +0300)
 src/w32heap.c (malloc_after_dump, realloc_after_dump): Update the
 emulated break value only if it goes up.
 (sbrk): Add assertion that the INCREMENT argument is strictly
 zero.  Improve and correct the commentary.

src/ChangeLog
src/w32heap.c

index c68adfcb5b14ff6f930389b433417f149c5be1d9..c22b925a1d7fc4c30d692a75d0699dd5b26e64bc 100644 (file)
@@ -1,3 +1,10 @@
+2014-06-02  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32heap.c (malloc_after_dump, realloc_after_dump): Update the
+       emulated break value only if it goes up.
+       (sbrk): Add assertion that the INCREMENT argument is strictly
+       zero.  Improve and correct the commentary.
+
 2014-06-02  Paul Eggert  <eggert@cs.ucla.edu>
 
        Improve AIX-related merge from emacs-24.
index 523df909165d88126dbca8b4af4f7110be66dbca..c0a17551d27ba30b5945ce4bf3999731c98ec25b 100644 (file)
@@ -299,9 +299,14 @@ malloc_after_dump (size_t size)
   /* Use the new private heap.  */
   void *p = HeapAlloc (heap, 0, size);
 
-  /* After dump, keep track of the last allocated byte for sbrk(0).  */
+  /* After dump, keep track of the "brk value" for sbrk(0).  */
   if (p)
-    data_region_end = p + size - 1;
+    {
+      unsigned char *new_brk = (unsigned char *)p + size;
+
+      if (new_brk > data_region_end)
+       data_region_end = new_brk;
+    }
   else
     errno = ENOMEM;
   return p;
@@ -391,9 +396,14 @@ realloc_after_dump (void *ptr, size_t size)
       else
        errno = ENOMEM;
     }
-  /* After dump, keep track of the last allocated byte for sbrk(0).  */
+  /* After dump, keep track of the "brk value" for sbrk(0).  */
   if (p)
-    data_region_end = p + size - 1;
+    {
+      unsigned char *new_brk = (unsigned char *)p + size;
+
+      if (new_brk > data_region_end)
+       data_region_end = new_brk;
+    }
   return p;
 }
 
@@ -497,10 +507,11 @@ getpagesize (void)
 void *
 sbrk (ptrdiff_t increment)
 {
-  /* The data_region_end address is the one of the last byte
-     allocated.  The sbrk() function is not emulated at all, except
-     for a 0 value of its parameter.  This is needed by the emacs lisp
-     function `memory-limit'.   */
+  /* data_region_end is the address beyond the last allocated byte.
+     The sbrk() function is not emulated at all, except for a 0 value
+     of its parameter.  This is needed by the Emacs Lisp function
+     `memory-limit'.  */
+  eassert (increment == 0);
   return data_region_end;
 }