emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r117235: Minor improvement of sbrk emulation on MS-W


From: Eli Zaretskii
Subject: [Emacs-diffs] trunk r117235: Minor improvement of sbrk emulation on MS-Windows.
Date: Mon, 02 Jun 2014 17:09:35 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117235
revision-id: address@hidden
parent: address@hidden
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Mon 2014-06-02 20:08:50 +0300
message:
  Minor improvement of sbrk emulation on MS-Windows.
  
   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.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/w32heap.c                  w32heap.c-20091113204419-o5vbwnq5f7feedwu-810
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-06-02 06:08:49 +0000
+++ b/src/ChangeLog     2014-06-02 17:08:50 +0000
@@ -1,3 +1,10 @@
+2014-06-02  Eli Zaretskii  <address@hidden>
+
+       * 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  <address@hidden>
 
        Improve AIX-related merge from emacs-24.

=== modified file 'src/w32heap.c'
--- a/src/w32heap.c     2014-06-01 15:54:56 +0000
+++ b/src/w32heap.c     2014-06-02 17:08:50 +0000
@@ -299,9 +299,14 @@
   /* 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 @@
       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 @@
 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;
 }
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]