-/* Unlinks a lookup table entry from the table; does not free it. */
-void lookup_table_unlink(struct lookup_table *table,
- struct lookup_table_entry *lte)
-{
- size_t pos;
- struct lookup_table_entry *prev, *cur_entry, *next;
-
- pos = lte->hash_short % table->capacity;
- prev = NULL;
- cur_entry = table->array[pos];
-
- while (cur_entry) {
- next = cur_entry->next;
- if (cur_entry == lte) {
- if (prev)
- prev->next = next;
- else
- table->array[pos] = next;
- table->num_entries--;
- return;
- }
- prev = cur_entry;
- cur_entry = next;
- }
-}
-
-
-/* Decrement the reference count for the dentry having hash value @hash in the
- * lookup table. The lookup table entry is unlinked and freed if there are no
- * references to in remaining. */
-struct lookup_table_entry *
-lookup_table_decrement_refcnt(struct lookup_table* table, const u8 hash[])
-{
- size_t pos = *(size_t*)hash % table->capacity;
- struct lookup_table_entry *prev = NULL;
- struct lookup_table_entry *entry = table->array[pos];
- struct lookup_table_entry *next;
- while (entry) {
- next = entry->next;
- if (memcmp(hash, entry->hash, WIM_HASH_SIZE) == 0) {
- wimlib_assert(entry->refcnt != 0);
- if (--entry->refcnt == 0) {
- if (entry->num_opened_fds == 0) {
- free_lookup_table_entry(entry);
- entry = NULL;
- }
- if (prev)
- prev->next = next;
- else
- table->array[pos] = next;
- break;
- }
- }
- prev = entry;
- entry = next;
- }
- return entry;
-}