]> wimlib.net Git - wimlib/blobdiff - src/wim.c
blob_table: decrease initial blob table size
[wimlib] / src / wim.c
index e01131ddffabfdc1504fc3b828d762f880ba526e..43b25aca950d7e1aecac523de7fc73399d0274a0 100644 (file)
--- a/src/wim.c
+++ b/src/wim.c
@@ -177,7 +177,7 @@ wimlib_create_new_wim(enum wimlib_compression_type ctype, WIMStruct **wim_ret)
                return WIMLIB_ERR_NOMEM;
 
        wim->xml_info = xml_new_info_struct();
-       wim->blob_table = new_blob_table(9001);
+       wim->blob_table = new_blob_table(64);
        if (!wim->xml_info || !wim->blob_table) {
                wimlib_free(wim);
                return WIMLIB_ERR_NOMEM;
@@ -729,7 +729,7 @@ begin_read(WIMStruct *wim, const void *wim_filename_or_fd, int open_flags)
        }
 
        if (open_flags & WIMLIB_OPEN_FLAG_FROM_PIPE) {
-               wim->blob_table = new_blob_table(9001);
+               wim->blob_table = new_blob_table(64);
                if (!wim->blob_table)
                        return WIMLIB_ERR_NOMEM;
        } else {
@@ -867,10 +867,14 @@ can_modify_wim(WIMStruct *wim)
        return 0;
 }
 
-/* Free a WIMStruct after no more resources reference it.  */
+/* Release a reference to a WIMStruct.  If the reference count reaches 0, the
+ * WIMStruct is freed.  */
 void
-finalize_wim_struct(WIMStruct *wim)
+wim_decrement_refcnt(WIMStruct *wim)
 {
+       wimlib_assert(wim->refcnt > 0);
+       if (--wim->refcnt != 0)
+               return;
        if (filedes_valid(&wim->in_fd))
                filedes_close(&wim->in_fd);
        if (filedes_valid(&wim->out_fd))
@@ -901,9 +905,7 @@ wimlib_free(WIMStruct *wim)
                wim->image_metadata = NULL;
        }
 
-       wimlib_assert(wim->refcnt > 0);
-       if (--wim->refcnt == 0)
-               finalize_wim_struct(wim);
+       wim_decrement_refcnt(wim);
 }
 
 static bool