X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Flookup_table.c;h=11dd2a37dd7bdc5217fc102d4075a50c11b92ead;hb=0f06c020c67371fe4dffaeb1622d81e60006e02c;hp=0538dd050c9c4e991ae74be48f596e7aa3233043;hpb=e176e9731e696562bab8de7b9bd34c019deef3e8;p=wimlib diff --git a/src/lookup_table.c b/src/lookup_table.c index 0538dd05..11dd2a37 100644 --- a/src/lookup_table.c +++ b/src/lookup_table.c @@ -212,6 +212,43 @@ free_lookup_table(struct wim_lookup_table *table) } } +static void +lookup_table_insert_raw(struct wim_lookup_table *table, + struct wim_lookup_table_entry *lte) +{ + size_t i = lte->hash_short % table->capacity; + + hlist_add_head(<e->hash_list, &table->array[i]); +} + +static void +enlarge_lookup_table(struct wim_lookup_table *table) +{ + size_t old_capacity, new_capacity; + struct hlist_head *old_array, *new_array; + struct wim_lookup_table_entry *lte; + struct hlist_node *cur, *tmp; + size_t i; + + old_capacity = table->capacity; + new_capacity = old_capacity * 2; + new_array = CALLOC(new_capacity, sizeof(struct hlist_head)); + if (new_array == NULL) + return; + old_array = table->array; + table->array = new_array; + table->capacity = new_capacity; + + for (i = 0; i < old_capacity; i++) { + hlist_for_each_entry_safe(lte, cur, tmp, &old_array[i], hash_list) { + hlist_del(<e->hash_list); + lookup_table_insert_raw(table, lte); + } + } + FREE(old_array); +} + + /* * Inserts an entry into the lookup table. * @@ -222,11 +259,9 @@ void lookup_table_insert(struct wim_lookup_table *table, struct wim_lookup_table_entry *lte) { - size_t i = lte->hash_short % table->capacity; - hlist_add_head(<e->hash_list, &table->array[i]); - - /* XXX Make the table grow when too many entries have been inserted. */ - table->num_entries++; + lookup_table_insert_raw(table, lte); + if (++table->num_entries > table->capacity) + enlarge_lookup_table(table); } static void @@ -288,7 +323,6 @@ for_lookup_table_entry(struct wim_lookup_table *table, hlist_for_each_entry_safe(lte, pos, tmp, &table->array[i], hash_list) { - wimlib_assert2(!(lte->resource_entry.flags & WIM_RESHDR_FLAG_METADATA)); ret = visitor(lte, arg); if (ret) return ret; @@ -578,6 +612,9 @@ read_wim_lookup_table(WIMStruct *wim) reshdr.size_in_wim, reshdr.uncompressed_size, reshdr.offset_in_wim, reshdr.flags); + if (wim->hdr.wim_version == WIM_VERSION_DEFAULT) + reshdr.flags &= ~WIM_RESHDR_FLAG_PACKED_STREAMS; + cur_entry = new_lookup_table_entry(); if (cur_entry == NULL) { ERROR("Not enough memory to read lookup table!"); @@ -831,8 +868,7 @@ write_wim_lookup_table_from_stream_list(struct list_head *stream_list, struct filedes *out_fd, u16 part_number, struct wim_reshdr *out_reshdr, - int write_resource_flags, - struct wimlib_lzx_context **comp_ctx) + int write_resource_flags) { size_t table_size; struct wim_lookup_table_entry *lte; @@ -912,8 +948,7 @@ write_wim_lookup_table_from_stream_list(struct list_head *stream_list, 0, out_reshdr, NULL, - write_resource_flags, - comp_ctx); + write_resource_flags); FREE(table_buf); DEBUG("ret=%d", ret); return ret; @@ -1139,7 +1174,7 @@ wim_pathname_to_stream(WIMStruct *wim, } } - dentry = get_dentry(wim, path); + dentry = get_dentry(wim, path, WIMLIB_CASE_SENSITIVE); if (p) *p = T(':'); if (!dentry)