VirtualBox

Changeset 1899 in kBuild


Ignore:
Timestamp:
Oct 21, 2008 1:51:48 AM (16 years ago)
Author:
bird
Message:

kmk: strcache2 - some alignment fixes.

File:
1 edited

Legend:

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

    r1897 r1899  
    7474  struct strcache2_seg *seg;
    7575  size_t size;
     76  size_t off;
    7677
    7778  size = cache->def_seg_size;
    78   if (size < (size_t)minlen + sizeof (struct strcache2_seg))
     79  if (size < (size_t)minlen + sizeof (struct strcache2_seg) + STRCACHE2_ENTRY_ALIGNMENT)
    7980    {
    8081      size = (size_t)minlen * 2;
     
    8384
    8485  seg = xmalloc (size);
    85   seg->cursor = seg->start = (char *)(seg + 1);
    86   seg->size = seg->avail = size - sizeof (struct strcache2_seg);
     86  seg->start = (char *)(seg + 1);
     87  seg->size  = size - sizeof (struct strcache2_seg);
     88  off = (size_t)seg->start & (STRCACHE2_ENTRY_ALIGNMENT - 1);
     89  if (off)
     90    {
     91      seg->start += off;
     92      seg->size  -= off;
     93    }
    8794  assert (seg->size > minlen);
     95  seg->cursor = seg->start;
     96  seg->avail  = seg->size;
    8897
    8998  seg->next = cache->seg_head;
     
    539548
    540549  entry = (struct strcache2_entry *) seg->cursor;
     550  assert ((size_t)entry & (STRCACHE2_ENTRY_ALIGNMENT - 1));
    541551  seg->cursor += size;
    542552  seg->avail -= size;
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