X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fwim.c;h=3d6febf1ee7898a96a96a65e0941fa09bab27c2b;hb=b61e9afca45dacd9baefbcfa17dbea2af75259b8;hp=2883b6a7b93a00dbcb4c0dacca58ecc72c12ec03;hpb=26fdf3f709adf52521e1cf962095987a3e0e2e00;p=wimlib diff --git a/src/wim.c b/src/wim.c index 2883b6a7..3d6febf1 100644 --- a/src/wim.c +++ b/src/wim.c @@ -25,10 +25,14 @@ */ #include "config.h" +#include #include #include +#include "dentry.h" + #ifdef WITH_NTFS_3G +#include #include #endif @@ -55,7 +59,14 @@ static int print_files(WIMStruct *w) WIMStruct *new_wim_struct() { - return CALLOC(1, sizeof(WIMStruct)); + WIMStruct *w = CALLOC(1, sizeof(WIMStruct)); + if (pthread_mutex_init(&w->fp_tab_mutex, NULL) != 0) { + ERROR_WITH_ERRNO("Failed to initialize mutex"); + FREE(w); + w = NULL; + } + return w; + } /* @@ -405,7 +416,7 @@ static int begin_read(WIMStruct *w, const char *in_wim_path, int open_flags) DEBUG("Reading the WIM file `%s'", in_wim_path); - w->filename = STRDUP(in_wim_path); + w->filename = realpath(in_wim_path, NULL); if (!w->filename) { ERROR("Failed to allocate memory for WIM filename"); return WIMLIB_ERR_NOMEM; @@ -567,6 +578,14 @@ WIMLIBAPI void wimlib_free(WIMStruct *w) if (w->out_fp) fclose(w->out_fp); + if (w->fp_tab) { + for (size_t i = 0; i < w->num_allocated_fps; i++) + if (w->fp_tab[i]) + fclose(w->fp_tab[i]); + FREE(w->fp_tab); + } + pthread_mutex_destroy(&w->fp_tab_mutex); + free_lookup_table(w->lookup_table); FREE(w->filename);