VirtualBox

Changeset 1876 in kBuild for trunk/src/kmk


Ignore:
Timestamp:
Oct 17, 2008 1:02:35 AM (16 years ago)
Author:
bird
Message:

kmk/alloccache: item size alignment.

File:
1 edited

Legend:

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

    r1872 r1876  
    12001200                 void *(*grow_alloc)(void *grow_arg, unsigned int size), void *grow_arg)
    12011201{
    1202   /* ensure aligned and min sizeof (struct alloccache_free_ent). */
    1203   if (size & (sizeof (void *) - 1))
    1204     size += sizeof (void *) - (size & (sizeof (void *) - 1));
    1205 
     1202  unsigned act_size;
     1203
     1204  /* ensure OK alignment and min sizeof (struct alloccache_free_ent). */
     1205  if (size <= sizeof (struct alloccache_free_ent))
     1206    act_size = sizeof (struct alloccache_free_ent);
     1207  else if (size <= 32)
     1208    {
     1209      act_size = 4;
     1210      while (act_size < size)
     1211        act_size <<= 1;
     1212    }
     1213  else
     1214    act_size = (size + 31U) & ~(size_t)31;
     1215
     1216  /* align the structure. */
    12061217  cache->free_start  = NULL;
    12071218  cache->free_end    = NULL;
    12081219  cache->free_head   = NULL;
    1209   cache->size        = size;
     1220  cache->size        = act_size;
    12101221  cache->alloc_count = 0;
    12111222  cache->total_count = 0;
     
    12141225  cache->grow_alloc  = grow_alloc ? grow_alloc : alloccache_default_grow_alloc;
    12151226
     1227  /* link it. */
    12161228  cache->next        = alloccache_head;
    12171229  alloccache_head    = cache;
     
    12231235                 void (*term_free)(void *term_arg, void *ptr, unsigned int size), void *term_arg)
    12241236{
    1225     cache->size = 0;
     1237    /*cache->size = 0;*/
     1238    (void)cache;
    12261239    (void)term_free;
    12271240    (void)term_arg;
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