]> code.delx.au - gnu-emacs/blobdiff - src/ralloc.c
*** empty log message ***
[gnu-emacs] / src / ralloc.c
index 5373212a48361323e10a675e50f3d99f6829a157..183db755412fd663d56ef8f290c11572d6ea7434 100644 (file)
@@ -363,7 +363,18 @@ relinquish ()
        }
 
       if ((*real_morecore) (- excess) == 0)
-       abort ();
+       {
+         /* If the system didn't want that much memory back, adjust
+             the end of the last heap to reflect that.  This can occur
+             if break_value is still within the original data segment.  */
+         last_heap->end += excess;
+         /* Make sure that the result of the adjustment is accurate.
+             It should be, for the else clause above; the other case,
+             which returns the entire last heap to the system, seems
+             unlikely to trigger this mode of failure.  */
+         if (last_heap->end != (*real_morecore) (0))
+           abort ();
+       }
     }
 }
 
@@ -1150,6 +1161,24 @@ r_alloc_init ()
   virtual_break_value = break_value = first_heap->bloc_start = first_heap->end;
   use_relocatable_buffers = 1;
 }
+
+#if defined (emacs) && defined (DOUG_LEA_MALLOC)
+
+/* Reinitialize the morecore hook variables after restarting a dumped
+   Emacs.  This is needed when using Doug Lea's malloc from GNU libc.  */
+void
+r_alloc_reinit ()
+{
+  /* Only do this if the hook has been reset, so that we don't get an
+     infinite loop, in case Emacs was linked statically.  */
+  if (__morecore != r_alloc_sbrk)
+    {
+      real_morecore = __morecore;
+      __morecore = r_alloc_sbrk;
+    }
+}
+#endif
+
 #ifdef DEBUG
 #include <assert.h>