]> wimlib.net Git - wimlib/blobdiff - src/symlink.c
Make lookup table use hlist
[wimlib] / src / symlink.c
index f7fa10d4a89b2ce4e55024749be8ec8b10c6f368..f16d8c22470e20f084434aa4df35c342ef705be3 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * Copyright (C) 2012 Eric Biggers
+ *
+ * This file is part of wimlib, a library for working with WIM files.
+ *
+ * wimlib is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with wimlib; if not, see http://www.gnu.org/licenses/.
+ */
+
 #include "dentry.h"
 #include "io.h"
 #include "lookup_table.h"
@@ -196,7 +215,9 @@ static int dentry_set_symlink_buf(struct dentry *dentry,
        if (!ads_entries)
                return WIMLIB_ERR_NOMEM;
        memcpy(ads_entries[1].hash, symlink_buf_hash, WIM_HASH_SIZE);
-       dentry_free_ads_entries(dentry);
+       wimlib_assert(dentry->num_ads == 0);
+       wimlib_assert(!dentry->ads_entries);
+       /*dentry_free_ads_entries(dentry);*/
        dentry->num_ads = 2;
        dentry->ads_entries = ads_entries;
        return 0;
@@ -226,6 +247,7 @@ int dentry_set_symlink(struct dentry *dentry, const char *target,
 
        if (existing_lte) {
                existing_lte->refcnt++;
+               lte = existing_lte;
        } else {
                DEBUG("Creating new lookup table entry for symlink buf");
                lte = new_lookup_table_entry();
@@ -253,7 +275,8 @@ int dentry_set_symlink(struct dentry *dentry, const char *target,
                *lte_ret = lte;
        return 0;
 out_free_lte:
-       FREE(lte);
+       if (lte != existing_lte)
+               FREE(lte);
 out_free_symlink_buf:
        FREE(symlink_buf);
        return ret;