VirtualBox

Changeset 2633 in kBuild


Ignore:
Timestamp:
Sep 8, 2012 11:18:59 PM (12 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.

Location:
trunk/src/kmk
Files:
2 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
  • trunk/src/kmk/make.h

    r2591 r2633  
    639639alloccache_alloc (struct alloccache *cache)
    640640{
    641   struct alloccache_free_ent *f = cache->free_head;
     641  struct alloccache_free_ent *f;
     642# ifndef CONFIG_WITH_ALLOCCACHE_DEBUG
     643  f = cache->free_head;
    642644  if (f)
    643645    cache->free_head = f->next;
     
    648650    }
    649651  else
     652# endif
    650653    f = alloccache_alloc_grow (cache);
    651654  MAKE_STATS(cache->alloc_count++;);
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