-/* Write a list of streams, taking into account that some streams may be
- * duplicates that are checksummed and discarded on the fly, and also delegating
- * the actual writing of a stream to a function @write_stream_cb, which is
- * passed the context @write_stream_ctx. */
-static int
-do_write_stream_list(struct list_head *stream_list,
- struct wim_lookup_table *lookup_table,
- int (*write_stream_cb)(struct wim_lookup_table_entry *, void *),
- void *write_stream_ctx,
- struct write_streams_progress_data *progress_data)
-{
- int ret = 0;
- struct wim_lookup_table_entry *lte;
- bool stream_discarded;
-
- /* For each stream in @stream_list ... */
- while (!list_empty(stream_list)) {
- stream_discarded = false;
- lte = container_of(stream_list->next,
- struct wim_lookup_table_entry,
- write_streams_list);
- list_del(<e->write_streams_list);
- if (lte->unhashed && !lte->unique_size) {
- /* Unhashed stream that shares a size with some other
- * stream in the WIM we are writing. The stream must be
- * checksummed to know if we need to write it or not. */
- struct wim_lookup_table_entry *tmp;
- u32 orig_out_refcnt = lte->out_refcnt;
-
- ret = hash_unhashed_stream(lte, lookup_table, &tmp);
- if (ret)
- break;
- if (tmp != lte) {
- /* We found a duplicate stream. 'lte' was
- * freed, so replace it with the duplicate. */
- lte = tmp;
-
- /* 'out_refcnt' was transferred to the
- * duplicate, and we can detect if the duplicate
- * stream was already referenced for writing by
- * checking if its 'out_refcnt' is higher than
- * that of the original stream. In such cases,
- * the current stream can be discarded. We can
- * also discard the current stream if it was
- * previously marked as filtered (e.g. already
- * present in the WIM being written). */
- if (lte->out_refcnt > orig_out_refcnt ||
- lte->filtered) {
- DEBUG("Discarding duplicate stream of "
- "length %"PRIu64,
- lte->size);
- lte->no_progress = 0;
- stream_discarded = true;
- goto skip_to_progress;
- }
- }
- }
-
- /* Here, @lte is either a hashed stream or an unhashed stream
- * with a unique size. In either case we know that the stream
- * has to be written. In either case the SHA1 message digest
- * will be calculated over the stream while writing it; however,
- * in the former case this is done merely to check the data,
- * while in the latter case this is done because we do not have
- * the SHA1 message digest yet. */
- wimlib_assert(lte->out_refcnt != 0);
- lte->deferred = 0;
- lte->no_progress = 0;
- ret = (*write_stream_cb)(lte, write_stream_ctx);