From e9ea88602558419972b935f1c68ea80119c924ef Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 25 Oct 2012 17:21:51 -0500 Subject: [PATCH] image delete cleanup --- src/modify.c | 13 ++++--------- src/wimlib.h | 8 ++++++-- src/xml.c | 3 +++ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/modify.c b/src/modify.c index 3e7e1c56..bafee183 100644 --- a/src/modify.c +++ b/src/modify.c @@ -2,7 +2,7 @@ * 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. */ @@ -570,7 +570,6 @@ out: */ WIMLIBAPI int wimlib_delete_image(WIMStruct *w, int image) { - int num_images; int i; int ret; @@ -580,11 +579,8 @@ WIMLIBAPI int wimlib_delete_image(WIMStruct *w, int image) } 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; } @@ -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. */ - 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], diff --git a/src/wimlib.h b/src/wimlib.h index 2b6f8f24..d4aa8a64 100644 --- a/src/wimlib.h +++ b/src/wimlib.h @@ -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. - * @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 diff --git a/src/xml.c b/src/xml.c index ff792520..4a09103c 100644 --- 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->hal); 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); + FREE(windows_info->default_language); FREE(windows_info->system_root); } -- 2.43.0