]> wimlib.net Git - wimlib/blobdiff - src/xml.c
add image cleanups
[wimlib] / src / xml.c
index eb963aabe882b4d44c46c9cd37ce7d96dff8f1c6..440398954a3d4e53b9c48a2bd8f8238a0c710052 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->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);
 }
 
@@ -818,6 +821,11 @@ static int clone_windows_info(const struct windows_info *old,
                return WIMLIB_ERR_NOMEM;
        if (old->system_root && !(new->system_root = STRDUP(old->system_root)))
                return WIMLIB_ERR_NOMEM;
+       if (old->windows_version_exists) {
+               new->windows_version_exists = true;
+               memcpy(&new->windows_version, &old->windows_version,
+                      sizeof(old->windows_version));
+       }
        return 0;
 }
 
@@ -861,7 +869,11 @@ static int clone_image_info(const struct image_info *old, struct image_info *new
  *
  * @dest_image_name and @dest_image_description are ignored if they are NULL;
  * otherwise, they are used to override the image name and/or image description
- * from the XML data in the source WIM file. */
+ * from the XML data in the source WIM file.
+ *
+ * On failure, WIMLIB_ERR_NOMEM is returned and no changes are made.  Otherwise,
+ * 0 is returned and the WIM information at *new_wim_info_p is modified.
+ */
 int xml_export_image(const struct wim_info *old_wim_info, 
                     int image, 
                     struct wim_info **new_wim_info_p, 
@@ -876,7 +888,6 @@ int xml_export_image(const struct wim_info *old_wim_info,
 
        wimlib_assert(image >= 1 && image <= old_wim_info->num_images);
 
-
        if (*new_wim_info_p) {
                new_wim_info = *new_wim_info_p;
        } else {
@@ -961,15 +972,6 @@ void xml_set_memory_allocator(void *(*malloc_func)(size_t),
 }
 #endif
 
-/* Parameters for calculate_dentry_statistics(). */
-struct image_statistics {
-       struct lookup_table *lookup_table;
-       u64 *dir_count;
-       u64 *file_count;
-       u64 *total_bytes;
-       u64 *hard_link_bytes;
-};
-
 static int calculate_dentry_statistics(struct dentry *dentry, void *arg)
 {
        struct image_info *info = arg; 
@@ -980,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
@@ -1107,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;