Lines Matching refs:hash
698 static void hash_clear(xhash *hash) in hash_clear() argument
703 for (i = 0; i < hash->csize; i++) { in hash_clear()
704 hi = hash->items[i]; in hash_clear()
712 hash->items[i] = NULL; in hash_clear()
714 hash->glen = hash->nel = 0; in hash_clear()
718 static void hash_free(xhash *hash)
720 hash_clear(hash);
721 free(hash->items);
722 free(hash);
727 static NOINLINE void *hash_search3(xhash *hash, const char *name, unsigned idx) in hash_search3() argument
731 hi = hash->items[idx % hash->csize]; in hash_search3()
740 static void *hash_search(xhash *hash, const char *name) in hash_search() argument
742 return hash_search3(hash, name, hashidx(name)); in hash_search()
746 static void hash_rebuild(xhash *hash) in hash_rebuild() argument
751 if (hash->nprime == ARRAY_SIZE(PRIMES)) in hash_rebuild()
754 newsize = PRIMES[hash->nprime++]; in hash_rebuild()
757 for (i = 0; i < hash->csize; i++) { in hash_rebuild()
758 hi = hash->items[i]; in hash_rebuild()
768 free(hash->items); in hash_rebuild()
769 hash->csize = newsize; in hash_rebuild()
770 hash->items = newitems; in hash_rebuild()
774 static void *hash_find(xhash *hash, const char *name) in hash_find() argument
781 hi = hash_search3(hash, name, idx); in hash_find()
783 if (++hash->nel > hash->csize * 8) in hash_find()
784 hash_rebuild(hash); in hash_find()
790 idx = idx % hash->csize; in hash_find()
791 hi->next = hash->items[idx]; in hash_find()
792 hash->items[idx] = hi; in hash_find()
793 hash->glen += l; in hash_find()
798 #define findvar(hash, name) ((var*) hash_find((hash), (name))) argument
803 static void hash_remove(xhash *hash, const char *name) in hash_remove() argument
807 phi = &hash->items[hashidx(name) % hash->csize]; in hash_remove()
811 hash->glen -= (strlen(name) + 1); in hash_remove()
812 hash->nel--; in hash_remove()