X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fdentry.c;h=38b4efa60291db98cae4620e268153b1e2b8ec95;hp=862c6640c9bb54b9bef52610824604091b830e13;hb=b5fae0e5ddac332b25856e3df7556aa3ee7f69fb;hpb=814c6f33ee61315286430e5f0044a40061e94b82 diff --git a/src/dentry.c b/src/dentry.c index 862c6640..38b4efa6 100644 --- a/src/dentry.c +++ b/src/dentry.c @@ -925,6 +925,7 @@ _new_dentry_with_inode(const tchar *name, struct wim_dentry **dentry_ret, bool timeless) { struct wim_dentry *dentry; + struct wim_inode *inode; int ret; ret = new_dentry(name, &dentry); @@ -932,15 +933,16 @@ _new_dentry_with_inode(const tchar *name, struct wim_dentry **dentry_ret, return ret; if (timeless) - dentry->d_inode = new_timeless_inode(); + inode = new_timeless_inode(); else - dentry->d_inode = new_inode(); - if (dentry->d_inode == NULL) { + inode = new_inode(); + if (!inode) { free_dentry(dentry); return WIMLIB_ERR_NOMEM; } - inode_add_dentry(dentry, dentry->d_inode); + d_associate(dentry, inode); + *dentry_ret = dentry; return 0; } @@ -997,19 +999,17 @@ dentry_tree_clear_inode_visited(struct wim_dentry *root) /* * Free a WIM dentry. * - * In addition to freeing the dentry itself, this decrements the link count of - * the corresponding inode (if any). If the inode's link count reaches 0, the - * inode is freed as well. + * In addition to freeing the dentry itself, this disassociates the dentry from + * its inode. If the inode is no longer in use, it will be freed as well. */ void free_dentry(struct wim_dentry *dentry) { if (dentry) { + d_disassociate(dentry); FREE(dentry->file_name); FREE(dentry->short_name); FREE(dentry->_full_path); - if (dentry->d_inode) - put_inode(dentry->d_inode); FREE(dentry); } }