diff src/alloc.c @ 386:4af0ddfb7c5b r21-2-8

Import from CVS: tag r21-2-8
author cvs
date Mon, 13 Aug 2007 11:08:50 +0200
parents 064ab7fed2e0
children 1f50e6fe4f3f
line wrap: on
line diff
--- a/src/alloc.c	Mon Aug 13 11:08:25 2007 +0200
+++ b/src/alloc.c	Mon Aug 13 11:08:50 2007 +0200
@@ -376,7 +376,7 @@
 void *
 xmalloc (size_t size)
 {
-  void *val = (void *) malloc (size);
+  void *val = malloc (size);
 
   if (!val && (size != 0)) memory_full ();
   return val;
@@ -385,7 +385,7 @@
 static void *
 xcalloc (size_t nelem, size_t elsize)
 {
-  void *val = (void *) calloc (nelem, elsize);
+  void *val = calloc (nelem, elsize);
 
   if (!val && (nelem != 0)) memory_full ();
   return val;
@@ -406,7 +406,7 @@
 {
   /* We must call malloc explicitly when BLOCK is 0, since some
      reallocs don't do this.  */
-  void *val = (void *) (block ? realloc (block, size) : malloc (size));
+  void *val = block ? realloc (block, size) : malloc (size);
 
   if (!val && (size != 0)) memory_full ();
   return val;
@@ -3378,8 +3378,7 @@
   if (type_index < 0 || type_index > max_lrecord_type
       || lrecord_implementations_table[type_index] != implementation)
     {
-      if (last_lrecord_type_index_assigned == max_lrecord_type)
-        abort ();
+      assert (last_lrecord_type_index_assigned < max_lrecord_type);
       type_index = ++last_lrecord_type_index_assigned;
       lrecord_implementations_table[type_index] = implementation;
       *(implementation->lrecord_type_index) = type_index;
@@ -3398,21 +3397,6 @@
   int instances_on_free_list;
 } lcrecord_stats [countof (lrecord_implementations_table)];
 
-
-static void
-reset_lcrecord_stats (void)
-{
-  int i;
-  for (i = 0; i < countof (lcrecord_stats); i++)
-    {
-      lcrecord_stats[i].instances_in_use = 0;
-      lcrecord_stats[i].bytes_in_use = 0;
-      lcrecord_stats[i].instances_freed = 0;
-      lcrecord_stats[i].bytes_freed = 0;
-      lcrecord_stats[i].instances_on_free_list = 0;
-    }
-}
-
 static void
 tick_lcrecord_stats (CONST struct lrecord_header *h, int free_p)
 {
@@ -3452,7 +3436,8 @@
   struct lcrecord_header *header;
   int num_used = 0;
   /* int total_size = 0; */
-  reset_lcrecord_stats ();
+
+  xzero (lcrecord_stats); /* Reset all statistics to 0. */
 
   /* First go through and call all the finalize methods.
      Then go through and free the objects.  There used to