From: Eric Biggers Date: Sun, 15 Jan 2017 01:00:13 +0000 (-0800) Subject: Don't generate GUID in wimlib_create_new_wim() X-Git-Tag: v1.11.0~5 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=831eeaad4513475ce947efaef16fc79ab3997444 Don't generate GUID in wimlib_create_new_wim() It's not necessary to generate a GUID in wimlib_create_new_wim() because one is generated later by wimlib_write(), and nothing seems to assume that a WIMStruct not yet backed by a file has a valid GUID. This saves a call to get_random_bytes(). Also remove some unnecessary initializations to 0. --- diff --git a/src/wim.c b/src/wim.c index 937b834b..ec345a93 100644 --- a/src/wim.c +++ b/src/wim.c @@ -172,31 +172,25 @@ wimlib_create_new_wim(enum wimlib_compression_type ctype, WIMStruct **wim_ret) if (!wim) return WIMLIB_ERR_NOMEM; - wim->xml_info = xml_new_info_struct(); - wim->blob_table = new_blob_table(64); - if (!wim->xml_info || !wim->blob_table) { - wimlib_free(wim); - return WIMLIB_ERR_NOMEM; - } - - /* Fill in wim->hdr with default values */ + /* Fill in wim->hdr with default values */ wim->hdr.magic = WIM_MAGIC; wim->hdr.wim_version = WIM_VERSION_DEFAULT; - wim->hdr.flags = 0; - wim->hdr.chunk_size = 0; - generate_guid(wim->hdr.guid); wim->hdr.part_number = 1; wim->hdr.total_parts = 1; - wim->hdr.image_count = 0; - wim->hdr.boot_idx = 0; - wim->compression_type = WIMLIB_COMPRESSION_TYPE_NONE; - wim->chunk_size = wim->hdr.chunk_size; - /* Set the output compression type */ + /* Set the output compression type */ wim->out_compression_type = ctype; wim->out_chunk_size = wim_default_nonsolid_chunk_size(ctype); + /* Allocate an empty XML info and blob table */ + wim->xml_info = xml_new_info_struct(); + wim->blob_table = new_blob_table(64); + if (!wim->xml_info || !wim->blob_table) { + wimlib_free(wim); + return WIMLIB_ERR_NOMEM; + } + *wim_ret = wim; return 0; }