-append_image_metadata(WIMStruct *wim, struct wim_image_metadata *imd)
-{
- struct wim_image_metadata **imd_array;
-
- DEBUG("Reallocating image metadata array for image_count = %u",
- wim->hdr.image_count + 1);
- imd_array = REALLOC(wim->image_metadata,
- sizeof(wim->image_metadata[0]) * (wim->hdr.image_count + 1));
-
- if (!imd_array)
- return WIMLIB_ERR_NOMEM;
- wim->image_metadata = imd_array;
- imd_array[wim->hdr.image_count++] = imd;
- return 0;
-}
-
-
-struct wim_image_metadata *
-new_image_metadata(void)
-{
- struct wim_image_metadata *imd;
-
- imd = CALLOC(1, sizeof(*imd));
- if (imd) {
- imd->refcnt = 1;
- INIT_LIST_HEAD(&imd->inode_list);
- INIT_LIST_HEAD(&imd->unhashed_streams);
- DEBUG("Created new image metadata (refcnt=1)");
- } else {
- ERROR_WITH_ERRNO("Failed to allocate new image metadata structure");
- }
- return imd;
-}
-
-struct wim_image_metadata **
-new_image_metadata_array(unsigned num_images)
-{
- struct wim_image_metadata **imd_array;
-
- DEBUG("Creating new image metadata array for %u images",
- num_images);
-
- imd_array = CALLOC(num_images, sizeof(imd_array[0]));
-
- if (!imd_array) {
- ERROR("Failed to allocate memory for %u image metadata structures",
- num_images);
- return NULL;
- }
- for (unsigned i = 0; i < num_images; i++) {
- imd_array[i] = new_image_metadata();
- if (!imd_array[i]) {
- for (unsigned j = 0; j < i; j++)
- put_image_metadata(imd_array[j], NULL);
- FREE(imd_array);
- return NULL;
- }
- }
- return imd_array;
-}
-
-/* Checksum all streams that are unhashed (other than the metadata streams),
- * merging them into the lookup table as needed. This is a no-op unless the
- * library has previously used to add or mount an image using the same
- * WIMStruct. */
-int
-wim_checksum_unhashed_streams(WIMStruct *wim)