VirtualBox

Changeset 1535 in kBuild for trunk/src/kmk/misc.c


Ignore:
Timestamp:
Apr 20, 2008 10:19:40 PM (17 years ago)
Author:
bird
Message:

Made the allocated and allocated-sum optional as they made xmalloc and xfree very expensive. New argument: --statistics / KMK_OPTS_STATISTICS=[1|0]

File:
1 edited

Legend:

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

    r1469 r1535  
    363363#ifdef CONFIG_WITH_MAKE_STATS
    364364  make_stats_allocations++;
    365   make_stats_allocated += SIZE_OF_HEAP_BLOCK (result);
    366   make_stats_allocated_sum += SIZE_OF_HEAP_BLOCK (result);
     365  if (make_expensive_statistics)
     366    {
     367      unsigned int actual_size = SIZE_OF_HEAP_BLOCK (result);
     368      make_stats_allocated += actual_size;
     369      make_stats_allocated_sum += actual_size;
     370    }
    367371#endif
    368372  return result;
     
    375379  void *result;
    376380#ifdef CONFIG_WITH_MAKE_STATS
    377   if (ptr != NULL)
    378     {
    379       make_stats_allocated -= SIZE_OF_HEAP_BLOCK (ptr);
    380       make_stats_allocated_sum -= SIZE_OF_HEAP_BLOCK (ptr);
     381  if (make_expensive_statistics && ptr != NULL)
     382    {
     383      unsigned int actual_size = SIZE_OF_HEAP_BLOCK (ptr);
     384      make_stats_allocated -= actual_size;
     385      make_stats_allocated_sum -= actual_size;
    381386    }
    382387#endif
     
    389394    fatal (NILF, _("virtual memory exhausted"));
    390395#ifdef CONFIG_WITH_MAKE_STATS
    391   make_stats_allocated += SIZE_OF_HEAP_BLOCK (result);
    392   make_stats_allocated_sum += SIZE_OF_HEAP_BLOCK (result);
     396  if (!ptr)
     397    make_stats_allocations++;
     398  if (make_expensive_statistics)
     399    {
     400      unsigned int actual_size = SIZE_OF_HEAP_BLOCK (result);
     401      make_stats_allocated += actual_size;
     402      make_stats_allocated_sum += actual_size;
     403    }
    393404#endif
    394405  return result;
     
    412423#ifdef CONFIG_WITH_MAKE_STATS
    413424  make_stats_allocations++;
    414   make_stats_allocated += SIZE_OF_HEAP_BLOCK (result);
    415   make_stats_allocated_sum += SIZE_OF_HEAP_BLOCK (result);
     425  if (make_expensive_statistics)
     426    {
     427      unsigned int actual_size = SIZE_OF_HEAP_BLOCK (result);
     428      make_stats_allocated += actual_size;
     429      make_stats_allocated_sum += actual_size;
     430    }
    416431#endif
    417432#ifdef HAVE_STRDUP
     
    950965void xfree(void *ptr)
    951966{
    952   if (ptr) 
     967  if (ptr)
    953968    {
    954969      make_stats_allocations--;
    955       make_stats_allocated -= SIZE_OF_HEAP_BLOCK (ptr);
     970      if (make_expensive_statistics)
     971        make_stats_allocated -= SIZE_OF_HEAP_BLOCK (ptr);
    956972      free (ptr);
    957973    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette