Changeset 1940 for trunk/src


Ignore:
Timestamp:
Oct 26, 2008, 2:59:40 AM (17 years ago)
Author:
bird
Message:

strcache2: fixed entry alignment.

File:
1 edited

Legend:

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

    r1925 r1940  
    697697  if (off)
    698698    {
     699      off = STRCACHE2_ENTRY_ALIGNMENT - off;
    699700      seg->start += off;
    700701      seg->size  -= off;
     
    737738
    738739  entry = (struct strcache2_entry *) seg->cursor;
    739   assert ((size_t)entry & (STRCACHE2_ENTRY_ALIGNMENT - 1));
     740  assert (!((size_t)entry & (STRCACHE2_ENTRY_ALIGNMENT - 1)));
    740741  seg->cursor += size;
    741742  seg->avail -= size;
     
    10541055  const char *end;
    10551056
    1056   if ((size_t)str & (sizeof (void *) - 1))
     1057  entry = (struct strcache2_entry const *)str - 1;
     1058  if ((size_t)entry & (STRCACHE2_ENTRY_ALIGNMENT - 1))
    10571059    {
    10581060      fprintf (stderr,
    1059                "strcache2[%s]: missaligned string %p\nstring: %s\n",
    1060                cache->name, (void *)str, str);
     1061               "strcache2[%s]: missaligned entry %p\nstring: %p=%s\n",
     1062               cache->name, (void *)entry, (void *)str, str);
    10611063      return -1;
    10621064    }
    10631065
    1064   entry = (struct strcache2_entry const *)str - 1;
    10651066  end = memchr (str, '\0', entry->length);
    10661067  if ((size_t)(end - str) == entry->length)
     
    10781079    {
    10791080      fprintf (stderr,
    1080                "strcache2[%s]: corrupt entry %p, hash#1: %x, expected %x;\nstring: %s\n",
     1081               "strcache2[%s]: corrupt entry %p, hash: %x, expected %x;\nstring: %s\n",
    10811082               cache->name, (void *)entry, hash, entry->hash, str);
    10821083      return -1;
Note: See TracChangeset for help on using the changeset viewer.