diff src/sheap.c @ 903:4a27df428c73

[xemacs-hg @ 2002-07-06 05:48:14 by andyp] sync with 21.4
author andyp
date Sat, 06 Jul 2002 05:48:22 +0000
parents 2b6fa2618f76
children 184461bc8de4
line wrap: on
line diff
--- a/src/sheap.c	Fri Jul 05 22:15:04 2002 +0000
+++ b/src/sheap.c	Sat Jul 06 05:48:22 2002 +0000
@@ -27,7 +27,7 @@
 #include <sheap-adjust.h>
 
 #define STATIC_HEAP_BASE	0x800000
-#define STATIC_HEAP_SLOP	0x40000
+#define STATIC_HEAP_SLOP	0xf0000
 #define STATIC_HEAP_SIZE \
 (STATIC_HEAP_BASE + SHEAP_ADJUSTMENT + STATIC_HEAP_SLOP)
 #define BLOCKSIZE	(1<<12)
@@ -106,7 +106,7 @@
 }
 
 static void
-sheap_adjust_h ()
+sheap_adjust_h (long adjust)
 {
   FILE *stream = retry_fopen ("sheap-adjust.h", "w");
 
@@ -117,8 +117,7 @@
   fprintf (stream,
 	   "/*\tDo not edit this file!\n"
 	   "\tAutomatically generated by XEmacs */\n"
-	   "# define SHEAP_ADJUSTMENT (%d)\n",
-	   ((static_heap_ptr - static_heap_buffer) - STATIC_HEAP_BASE));
+	   "# define SHEAP_ADJUSTMENT (%ld)\n", adjust);
   retry_fclose (stream);
 }
 
@@ -128,17 +127,20 @@
 {
   int rc = 0;
 
-  Bytecount lost = (STATIC_HEAP_BASE + STATIC_HEAP_SLOP + SHEAP_ADJUSTMENT)
+  Bytecount lost = STATIC_HEAP_SIZE
     - (static_heap_ptr - static_heap_buffer);
   char buf[200];
-  sprintf (buf, "Static heap usage: %ld of %ld",
+  sprintf (buf, "Static heap usage: %ld of %ld, slop is %ld",
                (long) (static_heap_ptr - static_heap_buffer),
-	   (long) (STATIC_HEAP_BASE + STATIC_HEAP_SLOP + SHEAP_ADJUSTMENT));
+	   (long) (STATIC_HEAP_SIZE),
+	   (long) STATIC_HEAP_SLOP);
 
   if (lost > STATIC_HEAP_SLOP) {
     sprintf (buf + strlen (buf), " -- %ldk wasted", (long)(lost/1024));
     if (die_if_pure_storage_exceeded) {
-      sheap_adjust_h();
+      sheap_adjust_h(STATIC_HEAP_SLOP - lost);
+      sprintf (buf + strlen (buf), " -- reset to %ldk", 
+	       (long) (STATIC_HEAP_SIZE + STATIC_HEAP_SLOP - lost));
       rc = -1;
     }
     message ("%s", buf);