X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Falloc.c;h=b53f506328aa630f3d7bb1d6dbc67fde0a04240a;hb=7049bf113e6f1c9f87b67a82b41a2778a25961e2;hp=509da0fb711453b76282cb9af49e0650708f600c;hpb=35adcaaeafb1fe93eaf00c39b48619e8f188ff3f;p=chise%2Fxemacs-chise.git.1 diff --git a/src/alloc.c b/src/alloc.c index 509da0f..b53f506 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -376,16 +376,20 @@ memory_full (void) void * xmalloc (size_t size) { - void *val = (void *) malloc (size); + void *val = malloc (size); if (!val && (size != 0)) memory_full (); return val; } +#ifdef xcalloc +#undef xcalloc +#endif + 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 +410,7 @@ xrealloc (void *block, size_t size) { /* 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 +3382,7 @@ lrecord_type_index (CONST struct lrecord_implementation *implementation) 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 +3401,6 @@ static struct 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 +3440,8 @@ sweep_lcrecords_1 (struct lcrecord_header **prev, int *used) 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