]> code.delx.au - gnu-emacs/blobdiff - src/w32heap.c
src/w32heap.c (init_heap): Fix typos in comments.
[gnu-emacs] / src / w32heap.c
index cc08dc372196354d10aa4b06b30196af1e4ef1e5..a65ca2df4661a6cf5196ce560abbb6e3cff6cce0 100644 (file)
@@ -219,9 +219,9 @@ init_heap (void)
       unsigned long enable_lfh = 2;
 
       /* After dumping, use a new private heap.  We explicitly enable
-         the low fragmentation heap here, for the sake of pre Vista
-         versions.  Note: this will harnlessly fail on Vista and
-         later, whyere the low fragmentation heap is enabled by
+         the low fragmentation heap (LFH) here, for the sake of pre
+         Vista versions.  Note: this will harmlessly fail on Vista and
+         later, where the low-fragmentation heap is enabled by
          default.  It will also fail on pre-Vista versions when Emacs
          is run under a debugger; set _NO_DEBUG_HEAP=1 in the
          environment before starting GDB to get low fragmentation heap
@@ -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;
 }
 
@@ -417,6 +427,12 @@ realloc_before_dump (void *ptr, size_t size)
          malloc_before_dump() and free_before_dump() will take care of
          reallocation.  */
       p = malloc_before_dump (size);
+      /* If SIZE is below MaxBlockSize, malloc_before_dump will try to
+        allocate it in the fixed heap.  If that fails, we could have
+        kept the block in its original place, above bc_limit, instead
+        of failing the call as below.  But this doesn't seem to be
+        worth the added complexity, as loadup allocates only a very
+        small number of large blocks, and never reallocates them.  */
       if (p)
        {
          CopyMemory (p, ptr, size);
@@ -491,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;
 }