-static int copy_lte_to_table(struct lookup_table_entry *lte, void *table)
-{
- struct lookup_table_entry *copy;
- copy = MALLOC(sizeof(struct lookup_table_entry));
- if (!copy)
- return WIMLIB_ERR_NOMEM;
- memcpy(copy, lte, sizeof(struct lookup_table_entry));
- lookup_table_insert(table, copy);
- return 0;
-}
-
-static int lookup_table_join(struct lookup_table *table,
- struct lookup_table *new)
-{
- return for_lookup_table_entry(new, copy_lte_to_table, table);
-}
-
-
-static int cmp_swms_by_part_number(const void *swm1, const void *swm2)
-{
- u16 partno_1 = (*(WIMStruct**)swm1)->hdr.part_number;
- u16 partno_2 = (*(WIMStruct**)swm2)->hdr.part_number;
- return (int)partno_1 - (int)partno_2;
-}
-
-/*
- * Sanity checks to make sure a set of WIMs correctly correspond to a spanned
- * set.
- *
- * @w:
- * Part 1 of the set.
- *
- * @additional_swms:
- * All parts of the set other than part 1.
- *
- * @num_additional_swms:
- * Number of WIMStructs in @additional_swms. Or, the total number of parts
- * in the set minus 1.
- *
- * @return:
- * 0 on success; WIMLIB_ERR_SPLIT_INVALID if the set is not valid.
- */
-int verify_swm_set(WIMStruct *w, WIMStruct **additional_swms,
- unsigned num_additional_swms)
-{
- unsigned total_parts = w->hdr.total_parts;
- int ctype;
- const u8 *guid;
-
- if (total_parts != num_additional_swms + 1) {
- ERROR("`%s' says there are %u parts in the spanned set, "
- "but %s%u part%s provided",
- w->filename, total_parts,
- (num_additional_swms + 1 < total_parts) ? "only " : "",
- num_additional_swms + 1,
- (num_additional_swms) ? "s were" : " was");
- return WIMLIB_ERR_SPLIT_INVALID;
- }
- if (w->hdr.part_number != 1) {
- ERROR("WIM `%s' is not the first part of the split WIM.",
- w->filename);
- return WIMLIB_ERR_SPLIT_INVALID;
- }
- for (unsigned i = 0; i < num_additional_swms; i++) {
- if (additional_swms[i]->hdr.total_parts != total_parts) {
- ERROR("WIM `%s' says there are %u parts in the spanned set, "
- "but %u parts were provided",
- additional_swms[i]->filename,
- additional_swms[i]->hdr.total_parts,
- total_parts);
- return WIMLIB_ERR_SPLIT_INVALID;
- }
- }
-
- /* keep track of ctype and guid just to make sure they are the same for
- * all the WIMs. */
- ctype = wimlib_get_compression_type(w);
- guid = w->hdr.guid;