VirtualBox

Changeset 1864 in kBuild for trunk/src/kmk/variable.c


Ignore:
Timestamp:
Oct 15, 2008 1:00:57 AM (16 years ago)
Author:
bird
Message:

kmk: use alloc caches for variables, variable sets and varaible set lists.

File:
1 edited

Legend:

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

    r1863 r1864  
    707707  /* Create a new variable definition and add it to the hash table.  */
    708708
     709#ifndef CONFIG_WITH_ALLOC_CACHES
    709710  v = xmalloc (sizeof (struct variable));
     711#else
     712  v = alloccache_alloc (&variable_cache);
     713#endif
    710714  v->name = savestring (name, length);
    711715  v->length = length;
     
    10161020  if (l == 0)
    10171021    {
     1022#ifndef CONFIG_WITH_ALLOC_CACHES
    10181023      l = (struct variable_set_list *)
    10191024        xmalloc (sizeof (struct variable_set_list));
    10201025      l->set = xmalloc (sizeof (struct variable_set));
     1026#else
     1027      l = (struct variable_set_list *)
     1028        alloccache_alloc (&variable_set_list_cache);
     1029      l->set = (struct variable_set *)
     1030        alloccache_alloc (&variable_set_cache);
     1031#endif
    10211032      hash_init (&l->set->table, PERFILE_VARIABLE_BUCKETS,
    10221033                 variable_hash_1, variable_hash_2, variable_hash_cmp);
     
    11211132  register struct variable_set *set;
    11221133
     1134#ifndef CONFIG_WITH_ALLOC_CACHES
    11231135  set = xmalloc (sizeof (struct variable_set));
     1136#else
     1137  set = (struct variable_set *) alloccache_alloc (&variable_set_cache);
     1138#endif
    11241139  hash_init (&set->table, SMALL_SCOPE_VARIABLE_BUCKETS,
    11251140             variable_hash_1, variable_hash_2, variable_hash_cmp);
    11261141
     1142#ifndef CONFIG_WITH_ALLOC_CACHES
    11271143  setlist = (struct variable_set_list *)
    11281144    xmalloc (sizeof (struct variable_set_list));
     1145#else
     1146  setlist = (struct variable_set_list *)
     1147    alloccache_alloc (&variable_set_list_cache);
     1148#endif
    11291149  setlist->set = set;
    11301150  setlist->next = current_variable_set_list;
     
    11451165{
    11461166  hash_map (&list->set->table, free_variable_name_and_value);
     1167#ifndef CONFIG_WITH_ALLOC_CACHES
    11471168  hash_free (&list->set->table, 1);
    11481169  free (list->set);
    11491170  free (list);
     1171#else
     1172  hash_free_cached (&list->set->table, 1, &variable_cache);
     1173  alloccache_free (&variable_set_cache, list->set);
     1174  alloccache_free (&variable_set_list_cache, list);
     1175#endif
    11501176}
    11511177
     
    12031229
    12041230  /* Free the one we no longer need.  */
     1231#ifndef CONFIG_WITH_ALLOC_CACHES
    12051232  free (setlist);
    12061233  hash_map (&set->table, free_variable_name_and_value);
    12071234  hash_free (&set->table, 1);
    12081235  free (set);
     1236#else
     1237  alloccache_free (&variable_set_list_cache, setlist);
     1238  hash_map (&set->table, free_variable_name_and_value);
     1239  hash_free_cached (&set->table, 1, &variable_cache);
     1240  alloccache_free (&variable_set_cache, set);
     1241#endif
    12091242}
    12101243
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