diff src/mc-alloc.c @ 3305:1043bbfa24cf

[xemacs-hg @ 2006-03-26 15:24:25 by crestani] 2006-03-26 Marcus Crestani <crestani@xemacs.org> * alloc.c (malloc_warning): Move function into scope of MALLOC_END, add MALLOC_END. * alloc.c (memory_full): Add memory shortage indication, adjust error messages. * mc-alloc.c: Add memory_shortage. * mc-alloc.c (expand_heap): If memory is short, allocate only the needed pages, not more. * mc-alloc.h: Add memory_shortage.
author crestani
date Sun, 26 Mar 2006 15:24:27 +0000
parents 619edf713d55
children 229bd619740a
line wrap: on
line diff
--- a/src/mc-alloc.c	Sun Mar 26 14:33:39 2006 +0000
+++ b/src/mc-alloc.c	Sun Mar 26 15:24:27 2006 +0000
@@ -411,6 +411,8 @@
 /*                           MC Allocator                               */
 /************************************************************************/
 
+/* Set to 1 if memory becomes short. */
+EMACS_INT memory_shortage;
 
 /*--- misc functions ---------------------------------------------------*/
 
@@ -1136,9 +1138,12 @@
   void *real_start;
 
   /* determine number of pages the heap should grow */
-  n_pages = needed_pages + (HEAP_SIZE / (PAGE_SIZE * HEAP_GROWTH_DIVISOR));
-  if (n_pages < MIN_HEAP_INCREASE)
-    n_pages = MIN_HEAP_INCREASE;
+  if (memory_shortage)
+    n_pages = needed_pages;
+  else
+    n_pages = max (MIN_HEAP_INCREASE, 
+		   needed_pages
+		   + (HEAP_SIZE / (PAGE_SIZE * HEAP_GROWTH_DIVISOR)));
 
   /* get the real values */
   real_size = (n_pages * PAGE_SIZE) + PAGE_SIZE;