pike.git / src / block_allocator.c

version» Context lines:

pike.git/src/block_allocator.c:445: Inside #if defined(DEBUG)
   }   #ifdef DEBUG    ba_print_htable(a);    fprintf(stderr, "ba_htable_delete(%p, %u)\n", p, n);    BA_ERROR("did not find index to delete.\n")   #endif   }      static INLINE void ba_htable_lookup(struct block_allocator * a,    const void * ptr) { -  ba_page p1, p2; -  p1 = a->pages[hash1(a, ptr) & BA_HASH_MASK(a)]; -  p2 = a->pages[hash2(a, ptr) & BA_HASH_MASK(a)]; +  ba_page p; +  ba_page_t h[2]; +  unsigned char c, b = 0; +  h[0] = hash1(a, ptr); +  h[1] = hash2(a, ptr);    -  while (p1 || p2) { -  if (p1) { -  if (BA_CHECK_PTR(a, p1, ptr)) { -  a->last_free = p1; +  c = ((uintptr_t)ptr >> (a->magnitude - 1)) & 1; +  + LOOKUP: +  p = a->pages[h[c] & BA_HASH_MASK(a)]; +  while (p) { +  if (BA_CHECK_PTR(a, p, ptr)) { +  a->last_free = p;    return;    } -  p1 = p1->hchain; +  p = p->hchain;    } -  if (p2) { -  if (BA_CHECK_PTR(a, p2, ptr)) { -  a->last_free = p2; -  return; +  c = !c; +  if (!(b++)) goto LOOKUP;   } -  p2 = p2->hchain; -  } -  } - } +       #ifdef BA_DEBUG   PMOD_EXPORT INLINE void ba_check_allocator(struct block_allocator * a,    char *fun, char *file, int line) {    ba_page_t n;    int bad = 0;    ba_page p;       if (a->empty_pages > a->num_pages) {    fprintf(stderr, "too many empty pages.\n");