Changeset 1438 for trunk/src/kmk/misc.c


Ignore:
Timestamp:
Mar 29, 2008, 2:49:27 AM (17 years ago)
Author:
bird
Message:

Added $(make-stats ) that provides access to memory and hash stats (if CONFIG_WITH_MAKE_STATS is defined).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/misc.c

    r909 r1438  
    361361  if (result == 0)
    362362    fatal (NILF, _("virtual memory exhausted"));
     363#ifdef CONFIG_WITH_MAKE_STATS
     364  make_stats_allocations++;
     365  make_stats_allocated += SIZE_OF_HEAP_BLOCK (result);
     366  make_stats_allocated_sum += SIZE_OF_HEAP_BLOCK (result);
     367#endif
    363368  return result;
    364369}
     
    369374{
    370375  void *result;
     376#ifdef CONFIG_WITH_MAKE_STATS
     377  make_stats_allocated -= SIZE_OF_HEAP_BLOCK (ptr);
     378  make_stats_allocated_sum -= SIZE_OF_HEAP_BLOCK (ptr);
     379#endif
    371380
    372381  /* Some older implementations of realloc() don't conform to ANSI.  */
     
    376385  if (result == 0)
    377386    fatal (NILF, _("virtual memory exhausted"));
     387#ifdef CONFIG_WITH_MAKE_STATS
     388  make_stats_allocated += SIZE_OF_HEAP_BLOCK (result);
     389  make_stats_allocated_sum += SIZE_OF_HEAP_BLOCK (result);
     390#endif
    378391  return result;
    379392}
     
    394407    fatal (NILF, _("virtual memory exhausted"));
    395408
     409#ifdef CONFIG_WITH_MAKE_STATS
     410  make_stats_allocations++;
     411  make_stats_allocated += SIZE_OF_HEAP_BLOCK (result);
     412  make_stats_allocated_sum += SIZE_OF_HEAP_BLOCK (result);
     413#endif
    396414#ifdef HAVE_STRDUP
    397415  return result;
     
    924942    }
    925943}
     944
     945#if defined(CONFIG_WITH_MAKE_STATS) && !defined(ELECTRIC_HEAP)
     946#undef free
     947void xfree(void *ptr)
     948{
     949  if (ptr)
     950    {
     951      make_stats_allocations--;
     952      make_stats_allocated -= SIZE_OF_HEAP_BLOCK (ptr);
     953      free (ptr);
     954    }
     955}
     956#endif
     957
Note: See TracChangeset for help on using the changeset viewer.