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

index bafee18375b398fcbd1f5c28d56246253d28fd8b..94df01dee0a3fe5f6ec096b817c9cf4282ebe835 100644 (file)
@@ -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],
index d4aa8a641675031c95e933335930b125a799a415..90bbe05514e4fc524c0a4a477728c18773109768 100644 (file)
@@ -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
index 4a09103ce4ccb36e9cc2ef30cf64cb8e6aa2a98c..440398954a3d4e53b9c48a2bd8f8238a0c710052 100644 (file)
--- 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;