pike.git / src / block_allocator.c

version» Context lines:

pike.git/src/block_allocator.c:312: Inside #if defined(DEBUG)
   fprintf(stderr, "ba_htable_delete(%p, %u)\n", ptr, n);    Pike_error("did not find index to delete.\n")   #endif   }      static INLINE ba_page_t ba_htable_lookup(const struct block_allocator * a,    const void * ptr) {   #ifdef COUNT    count_name = "hash";   #endif - #ifdef BA_DEBUG -  int c = 0; - #endif -  ba_page_t n; +     ba_page p; -  n = a->htable[hash1(a, ptr) & BA_HASH_MASK(a)]; -  while (n) { -  p = BA_PAGE(a, n); +  ba_page_t n1, n2; +  n1 = a->htable[hash1(a, ptr) & BA_HASH_MASK(a)]; +  n2 = a->htable[hash2(a, ptr) & BA_HASH_MASK(a)]; +  +  while (n1 || n2) { +  if (n1) { +  p = BA_PAGE(a, n1);    if (BA_CHECK_PTR(a, p, ptr)) { -  INC(good); -  return n; +  return n1;    } -  n = p->hchain; +  n1 = p->hchain;    } -  n = a->htable[hash2(a, ptr) & BA_HASH_MASK(a)]; -  while (n) { -  p = BA_PAGE(a, n); +  if (n2) { +  p = BA_PAGE(a, n2);    if (BA_CHECK_PTR(a, p, ptr)) { -  if (a->htable[hash1(a, ptr) & BA_HASH_MASK(a)]) -  INC(ugly); -  else INC(bad); -  return n; +  return n2;    } - #ifdef BA_DEBUG -  if (c++ > a->allocated) { -  Pike_error("hash chain is infinite\n"); +  n2 = p->hchain;    } - #endif -  n = p->hchain; +     }       return 0;   }      #ifdef BA_DEBUG   PMOD_EXPORT INLINE void ba_check_allocator(struct block_allocator * a,    char *fun, char *file, int line) {    unsigned int i = 0;    int bad = 0;