*/
/*
- * Copyright (C) 2012 Eric Biggers
+ * Copyright (C) 2012, 2013 Eric Biggers
*
* wimlib - Library for working with WIM files
*
int select_wim_image(WIMStruct *w, int image)
{
struct wim_image_metadata *imd;
+ int ret;
DEBUG("Selecting image %d", image);
INIT_HLIST_HEAD(&imd->inode_list);
}
}
-
w->current_image = image;
- imd = wim_get_current_image_metadata(w);
-
+ imd = &w->image_metadata[image - 1];
if (imd->root_dentry) {
- return 0;
+ ret = 0;
} else {
#ifdef ENABLE_DEBUG
DEBUG("Reading metadata resource specified by the following "
"lookup table entry:");
- print_lookup_table_entry(imd->metadata_lte);
+ print_lookup_table_entry(imd->metadata_lte, stdout);
#endif
- return read_metadata_resource(w, imd);
+ ret = read_metadata_resource(w, imd);
+ if (ret)
+ w->current_image = WIMLIB_NO_IMAGE;
}
+ return ret;
}
#endif
FREE(w);
}
+
+/* Get global memory allocations out of the way. Not strictly necessary in
+ * single-threaded programs like 'imagex'. */
+WIMLIBAPI int wimlib_global_init()
+{
+ libxml_global_init();
+ return iconv_global_init();
+}
+
+/* Free global memory allocations. Not strictly necessary if the process using
+ * wimlib is just about to exit (as is the case for 'imagex'). */
+WIMLIBAPI void wimlib_global_cleanup()
+{
+ libxml_global_cleanup();
+ iconv_global_cleanup();
+}