]> wimlib.net Git - wimlib/commitdiff
image delete cleanup
authorEric Biggers <ebiggers3@gmail.com>
Thu, 25 Oct 2012 22:21:51 +0000 (17:21 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Thu, 25 Oct 2012 22:21:51 +0000 (17:21 -0500)
src/modify.c
src/wimlib.h
src/xml.c

index 3e7e1c5684780f7fdf3a8a79c1f487bfae3bd73b..bafee18375b398fcbd1f5c28d56246253d28fd8b 100644 (file)
@@ -2,7 +2,7 @@
  * modify.c
  *
  * Support for modifying WIM files with image-level operations (delete an image,
  * modify.c
  *
  * Support for modifying WIM files with image-level operations (delete an image,
- * add an image, export an imagex from one WIM to another.)  There is nothing
+ * add an image, export an image from one WIM to another.)  There is nothing
  * here that lets you change individual files in the WIM; for that you will need
  * to look at the filesystem implementation in mount.c.
  */
  * here that lets you change individual files in the WIM; for that you will need
  * to look at the filesystem implementation in mount.c.
  */
@@ -570,7 +570,6 @@ out:
  */
 WIMLIBAPI int wimlib_delete_image(WIMStruct *w, int image)
 {
  */
 WIMLIBAPI int wimlib_delete_image(WIMStruct *w, int image)
 {
-       int num_images;
        int i;
        int ret;
 
        int i;
        int ret;
 
@@ -580,11 +579,8 @@ WIMLIBAPI int wimlib_delete_image(WIMStruct *w, int image)
        }
 
        if (image == WIM_ALL_IMAGES) {
        }
 
        if (image == WIM_ALL_IMAGES) {
-               num_images = w->hdr.image_count;
-               for (i = 1; i <= num_images; i++) {
-                       /* Always delete the first image, since by the end
-                        * there won't be any more than that!  */
-                       ret = wimlib_delete_image(w, 1);
+               for (i = w->hdr.image_count; i >= 1; i--) {
+                       ret = wimlib_delete_image(w, i);
                        if (ret != 0)
                                return ret;
                }
                        if (ret != 0)
                                return ret;
                }
@@ -602,8 +598,7 @@ WIMLIBAPI int wimlib_delete_image(WIMStruct *w, int image)
 
        /* Free the dentry tree, any lookup table entries that have their
         * refcnt decremented to 0, and the security data. */
 
        /* Free the dentry tree, any lookup table entries that have their
         * refcnt decremented to 0, and the security data. */
-       destroy_image_metadata(wim_get_current_image_metadata(w),
-                              w->lookup_table);
+       destroy_image_metadata(&w->image_metadata[image - 1], w->lookup_table);
 
        /* Get rid of the empty slot in the image metadata array. */
        memmove(&w->image_metadata[image - 1], &w->image_metadata[image],
 
        /* Get rid of the empty slot in the image metadata array. */
        memmove(&w->image_metadata[image - 1], &w->image_metadata[image],
index 2b6f8f2499daa967bf1fb271e534a04bef1bde93..d4aa8a641675031c95e933335930b125a799a415 100644 (file)
@@ -489,8 +489,12 @@ extern int wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
  * @param image
  *     The number of the image to delete, or ::WIM_ALL_IMAGES to delete all
  *     images.
  * @param image
  *     The number of the image to delete, or ::WIM_ALL_IMAGES to delete all
  *     images.
- * @return 0 on success; nonzero on error.  On error, @a wim is left in an
- * indeterminate state and should be freed with wimlib_free().
+ * @return 0 on success; nonzero on failure.  On failure, @a wim is guaranteed
+ * to be left unmodified only if @a image specified a single image.  If instead
+ * @a image was ::WIM_ALL_IMAGES and @a wim contained more than one image, it's
+ * possible for some but not all of the images to have been deleted when a
+ * failure status is returned.
+ *
  * @retval ::WIMLIB_ERR_DECOMPRESSION
  *     Could not decompress the metadata resource for @a image.
  * @retval ::WIMLIB_ERR_INVALID_DENTRY
  * @retval ::WIMLIB_ERR_DECOMPRESSION
  *     Could not decompress the metadata resource for @a image.
  * @retval ::WIMLIB_ERR_INVALID_DENTRY
index ff7925204017f869fca3b9f5a5169fd80c6b5951..4a09103ce4ccb36e9cc2ef30cf64cb8e6aa2a98c 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -209,10 +209,13 @@ static void destroy_windows_info(struct windows_info *windows_info)
        FREE(windows_info->product_name);
        FREE(windows_info->edition_id);
        FREE(windows_info->installation_type);
        FREE(windows_info->product_name);
        FREE(windows_info->edition_id);
        FREE(windows_info->installation_type);
+       FREE(windows_info->hal);
        FREE(windows_info->product_type);
        FREE(windows_info->product_type);
+       FREE(windows_info->product_suite);
        for (i = 0; i < windows_info->num_languages; i++)
                FREE(windows_info->languages[i]);
        FREE(windows_info->languages);
        for (i = 0; i < windows_info->num_languages; i++)
                FREE(windows_info->languages[i]);
        FREE(windows_info->languages);
+       FREE(windows_info->default_language);
        FREE(windows_info->system_root);
 }
 
        FREE(windows_info->system_root);
 }