VirtualBox

Changeset 2633 in kBuild for trunk/src/kmk/alloccache.c


Ignore:
Timestamp:
Sep 8, 2012 11:18:59 PM (13 years ago)
Author:
bird
Message:

kmk: CONFIG_WITH_ALLOCCACHE_DEBUG - for optionally turning the allocations over to the heap where they can be checked and fenced in.

File:
1 edited

Legend:

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

    r2413 r2633  
    5454alloccache_free (struct alloccache *cache, void *item)
    5555{
     56#ifndef CONFIG_WITH_ALLOCCACHE_DEBUG
    5657  struct alloccache_free_ent *f = (struct alloccache_free_ent *)item;
    57 #if 0 /*ndef NDEBUG*/
     58# if 0 /*ndef NDEBUG*/
    5859  struct alloccache_free_ent *c;
    5960  unsigned int i = 0;
     
    6162    MY_ASSERT_MSG (c != f && i < 0x10000000,
    6263                   ("i=%u total_count=%u\n", i, cache->total_count));
    63 #endif
     64# endif
    6465
    6566  f->next = cache->free_head;
    6667  cache->free_head = f;
    6768  MAKE_STATS(cache->free_count++;);
     69#else
     70  free(item);
     71#endif
    6872}
    6973
     
    7983alloccache_alloc_grow (struct alloccache *cache)
    8084{
     85#ifndef CONFIG_WITH_ALLOCCACHE_DEBUG
    8186  void *item;
    8287  unsigned int items = (64*1024 - 32) / cache->size;
     
    8590  cache->total_count+= items;
    8691
    87 #ifndef NDEBUG /* skip the first item so the heap can detect free(). */
     92# ifndef NDEBUG /* skip the first item so the heap can detect free(). */
    8893  cache->total_count--;
    8994  cache->free_start += cache->size;
    90 #endif
     95# endif
    9196
    9297  item = cache->free_start;
     
    9499  /* caller counts */
    95100  return (struct alloccache_free_ent *)item;
     101#else
     102  return (struct alloccache_free_ent *)xmalloc(cache->size);
     103#endif
    96104}
    97105
Note: See TracChangeset for help on using the changeset viewer.

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