From e5f14906472d2c8575d32100f06da365f70d3028 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 25 Oct 2012 17:59:11 -0500 Subject: [PATCH] add image cleanups --- src/modify.c | 11 +++++------ src/wimlib.h | 8 +++++--- src/xml.c | 7 +++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/modify.c b/src/modify.c index bafee183..94df01de 100644 --- a/src/modify.c +++ b/src/modify.c @@ -725,7 +725,7 @@ static int init_capture_config(const char *_config_str, size_t config_len, } next_p = eol + 1; - bytes_remaining -= (eol - p) + 1; + bytes_remaining -= (next_p - p); if (eol == p) continue; @@ -754,7 +754,6 @@ static int init_capture_config(const char *_config_str, size_t config_len, else if (p[0] == '[' && strrchr(p, ']')) { ERROR("Unknown capture configuration section `%s'", p); ret = WIMLIB_ERR_INVALID_CAPTURE_CONFIG; - goto out_destroy; } else switch (type) { case EXCLUSION_LIST: DEBUG("Adding pattern \"%s\" to exclusion list", p); @@ -777,7 +776,7 @@ static int init_capture_config(const char *_config_str, size_t config_len, "in a block (such as [ExclusionList])", line_no); ret = WIMLIB_ERR_INVALID_CAPTURE_CONFIG; - goto out_destroy; + break; } if (ret != 0) goto out_destroy; @@ -966,13 +965,13 @@ int do_add_image(WIMStruct *w, const char *dir, const char *name, DEBUG("Assigning hard link group IDs"); assign_inode_numbers(&inode_list); - if (flags & WIMLIB_ADD_IMAGE_FLAG_BOOT) - wimlib_set_boot_idx(w, w->hdr.image_count); - ret = xml_add_image(w, name); if (ret != 0) goto out_destroy_imd; + if (flags & WIMLIB_ADD_IMAGE_FLAG_BOOT) + wimlib_set_boot_idx(w, w->hdr.image_count); + return 0; out_destroy_imd: destroy_image_metadata(&w->image_metadata[w->hdr.image_count - 1], diff --git a/src/wimlib.h b/src/wimlib.h index d4aa8a64..90bbe055 100644 --- a/src/wimlib.h +++ b/src/wimlib.h @@ -480,8 +480,9 @@ extern int wimlib_create_new_wim(int ctype, WIMStruct **wim_ret); /** * Deletes an image, or all images, from a WIM file. * - * All file resources referenced by the image(s) being deleted are removed from - * the WIM if they are not referenced by any other images in the WIM. + * All streams referenced by the image(s) being deleted are removed from the + * lookup table of the WIM if they are not referenced by any other images in the + * WIM. * * @param wim * Pointer to the ::WIMStruct for the WIM file that contains the image(s) @@ -506,7 +507,8 @@ extern int wimlib_create_new_wim(int ctype, WIMStruct **wim_ret); * The metadata resource for @a image in the WIM is invalid. * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA * The security data for @a image in the WIM is invalid. - * @retval ::WIMLIB_ERR_NOMEM Failed to allocate needed memory. + * @retval ::WIMLIB_ERR_NOMEM + * Failed to allocate needed memory. * @retval ::WIMLIB_ERR_READ * Could not read the metadata resource for @a image from the WIM. * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED diff --git a/src/xml.c b/src/xml.c index 4a09103c..44039895 100644 --- a/src/xml.c +++ b/src/xml.c @@ -982,7 +982,7 @@ static int calculate_dentry_statistics(struct dentry *dentry, void *arg) /* Update directory count and file count. * * Each dentry counts as either a file or a directory, but not both. - * The root directory is an exception: it is not counted. + * The root directory is an exception: it is not counted at all. * * Symbolic links and junction points (and presumably other reparse * points) count as regular files. This is despite the fact that @@ -1109,10 +1109,9 @@ int xml_add_image(WIMStruct *w, const char *name) out_destroy_image_info: destroy_image_info(image_info); + wim_info->num_images--; out_free_wim_info: - if (w->wim_info) - wim_info->num_images--; - else + if (wim_info != w->wim_info) FREE(wim_info); ERROR("Out of memory"); return WIMLIB_ERR_NOMEM; -- 2.43.0