changeset 2723:c474585a3460

[xemacs-hg @ 2005-04-10 00:47:53 by crestani] New Allocator Fixes * dumper.c (pdump_get_mc_addr): Use clearer code. * dumper.c (pdump_put_mc_addr): Use clearer code. * emacs.c (main_1): Initialize the new allocator only once. * mc-alloc.c (get_page_header): Split up the assertions to better spot the problem. * mc-alloc.c (mc_alloc_1): Move definitions of local variables to the beginning of the function.
author crestani
date Sun, 10 Apr 2005 00:47:58 +0000
parents 65bc67c9185a
children 9e674e9b054e
files src/ChangeLog src/dumper.c src/emacs.c src/mc-alloc.c
diffstat 4 files changed, 22 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sat Apr 09 21:51:59 2005 +0000
+++ b/src/ChangeLog	Sun Apr 10 00:47:58 2005 +0000
@@ -1,3 +1,13 @@
+2005-04-10  Marcus Crestani  <crestani@xemacs.org>
+
+	* dumper.c (pdump_get_mc_addr): Use clearer code.
+	* dumper.c (pdump_put_mc_addr): Use clearer code.
+	* emacs.c (main_1): Initialize the new allocator only once.
+	* mc-alloc.c (get_page_header): Split up the assertions to better
+	spot the problem.
+	* mc-alloc.c (mc_alloc_1): Move definitions of local variables to
+	the beginning of the function.
+
 2005-04-01  Melvin Hadasht <melvin.hadasht@free.fr>
 
 	* text.c (new_dfc_convert_size): Move active code out of assert.
--- a/src/dumper.c	Sat Apr 09 21:51:59 2005 +0000
+++ b/src/dumper.c	Sun Apr 10 00:47:58 2005 +0000
@@ -537,7 +537,7 @@
 
   assert (obj != 0);
 
-  while ((mc_addr = &pdump_mc_hash[pos]) && (mc_addr->obj != 0))
+  while (((mc_addr = &pdump_mc_hash[pos]) != 0) && (mc_addr->obj != 0))
     {
       if (mc_addr->obj == obj)
 	return mc_addr->addr;
@@ -568,7 +568,7 @@
   mc_addr_elt *mc_addr;
   int pos = pdump_make_hash (obj);
 
-  while ((mc_addr = &pdump_mc_hash[pos]) && (mc_addr->obj != 0))
+  while (((mc_addr = &pdump_mc_hash[pos]) != 0) && (mc_addr->obj != 0))
     {
       if (mc_addr->obj == obj)
 	return;
--- a/src/emacs.c	Sat Apr 09 21:51:59 2005 +0000
+++ b/src/emacs.c	Sun Apr 10 00:47:58 2005 +0000
@@ -916,10 +916,13 @@
   if (!initialized)
 #endif
     {
-      init_mc_allocator ();
+      if (!restart)
+	{
+	  init_mc_allocator ();
 #ifdef MC_ALLOC_TYPE_STATS
-      init_lrecord_stats ();
+	  init_lrecord_stats ();
 #endif /* not MC_ALLOC_TYPE_STATS */
+	}
     }
 #endif /* MC_ALLOC */
 
--- a/src/mc-alloc.c	Sat Apr 09 21:51:59 2005 +0000
+++ b/src/mc-alloc.c	Sun Apr 10 00:47:58 2005 +0000
@@ -571,11 +571,12 @@
 {
   int l1_index = L1_INDEX (ptr);
   level_2_lookup_tree *l2 = PTR_LOOKUP_TABLE (l1_index);
+  assert (l2);
 #ifdef USE_HASH_TABLE
   while ((l2) && (LEVEL2_KEY (l2) != l1_index))
     l2 = LEVEL2_HASH_LINK (l2);
 #endif
-  assert (l2 && LEVEL2 (l2, L2_INDEX (ptr)));
+  assert (LEVEL2 (l2, L2_INDEX (ptr)));
   return LEVEL2 (l2, L2_INDEX (ptr));
 }
 
@@ -1414,13 +1415,14 @@
 mc_alloc_1 (size_t size, int managed)
 {
   page_list_header *plh = 0;
+  page_header *ph = 0;
+  void *result = 0;
+
   if (managed)
     plh = USED_HEAP_PAGES (get_used_list_index (size));
   else
     plh = UNMANAGED_HEAP_PAGES (get_unmanaged_list_index (size));
 
-  page_header *ph = 0;
-  void *result = 0;
   if (size == 0)
     return 0;
   if (size < PAGE_SIZE_DIV_2)