changeset 17346:f29f51d8a21f

(malloc_get_state, malloc_set_state): New declarations. (main): Restore internal malloc state when loading from dumped image. (Fdump_emacs): Copy internal malloc state for dumping, then free it.
author Richard M. Stallman <rms@gnu.org>
date Wed, 09 Apr 1997 04:00:10 +0000
parents 4e11e27ce1f1
children 94dbc8701ad1
files src/emacs.c
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/emacs.c	Wed Apr 09 03:59:08 1997 +0000
+++ b/src/emacs.c	Wed Apr 09 04:00:10 1997 +0000
@@ -81,6 +81,16 @@
   on subsequent starts.  */
 int initialized;
 
+#ifdef DOUG_LEA_MALLOC
+/* Preserves a pointer to the memory allocated that copies that
+   static data inside glibc's malloc.  */
+void *malloc_state_ptr;
+/* From glibc, a routine that returns a copy of the malloc internal state.  */
+extern void *malloc_get_state ();
+/* From glibc, a routine that overwrites the malloc internal state.  */
+extern void malloc_set_state ();
+#endif
+
 /* Variable whose value is symbol giving operating system type.  */
 Lisp_Object Vsystem_type;
 
@@ -486,6 +496,14 @@
   __sbrk (1);
 #endif
 
+#ifdef DOUG_LEA_MALLOC
+  if (initialized)
+    {
+      malloc_set_state (malloc_state_ptr);
+      free (malloc_state_ptr);
+    }
+#endif
+
   sort_args (argc, argv);
 
   if (argmatch (argv, argc, "-version", "--version", 3, NULL, &skip_args))
@@ -1510,8 +1528,14 @@
   memory_warnings (my_edata, malloc_warning);
 #endif /* not WINDOWSNT */
 #endif
+#ifdef DOUG_LEA_MALLOC
+  malloc_state_ptr = malloc_get_state ();
+#endif
   unexec (XSTRING (filename)->data,
 	  !NILP (symfile) ? XSTRING (symfile)->data : 0, my_edata, 0, 0);
+#ifdef DOUG_LEA_MALLOC
+  free (malloc_state_ptr);
+#endif
 #endif /* not VMS */
 
   Vpurify_flag = tem;