about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-11-13 16:54:51 +0100
committerLeah Neukirchen <leah@vuxu.org>2017-11-13 16:54:51 +0100
commit241895515a031f88ca4b3973ac71616b4522fa49 (patch)
tree08fe9f34e612c51aaafa6a970b5b67d9c2eaf7d3
parent3e8de361f5b23ec1a21caf5aa59b2cfd12370460 (diff)
downloadlr-241895515a031f88ca4b3973ac71616b4522fa49.tar.gz
lr-241895515a031f88ca4b3973ac71616b4522fa49.tar.xz
lr-241895515a031f88ca4b3973ac71616b4522fa49.zip
callback: free unregistered fileinfo immediately
-rw-r--r--lr.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lr.c b/lr.c
index acb2526..7d75f3f 100644
--- a/lr.c
+++ b/lr.c
@@ -2033,13 +2033,15 @@ callback(const char *fpath, const struct stat *sb, int depth, ino_t entries, off
 	if (Uflag) {
 		print_format(fi);
 		free_fi(fi);
+		return 0;
 	} else if (Bflag) {
-		if (initial) {
-			if (fi->depth == 0)
-				root = fitree_insert(root, fi);
+		if (initial && fi->depth == 0) {
+			root = fitree_insert(root, fi);
+		} else if (!initial && fi->depth == bflag_depth + 1) {
+			new_root = fitree_insert(new_root, fi);
 		} else {
-			if (fi->depth == bflag_depth + 1)
-				new_root = fitree_insert(new_root, fi);
+			free_fi(fi);
+			return 0;
 		}
 	} else {
 		// add to the tree, note that this will eliminate duplicate files