agendafs

A filesystem for your calendar.

git clone git://mccd.space/agendafs
commit c54832fbe8785da3c9b2bb743d16171cdbd55816
parent ab15561d753748e017de59133dcdbc2497409000
Author: Marc Coquand <marc@coquand.email>
Date:   Fri, 27 Jun 2025 22:00:29 +0100

Fix memory leaks

Still more to go though

Diffstat:
Mjournal_entry.c | 7++++++-
Mmain.c | 2+-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/journal_entry.c b/journal_entry.c
@@ -117,6 +117,7 @@ get_node_by_uuid(const char *target_uuid)
 	LOG("Full filename: '%s'", filename_original);
 
 	tree_node *node = hashmap_get(entries_original_ics, filename_original);
+	free(filename_original);
 	LOG("Found it: %b", node != NULL);
 	return node;
 }
@@ -631,9 +632,12 @@ load_journal_entries()
 			}
 		}
 	}
+	for (int i = 0; i < n_keys; i++) {
+		free(keys[i]);
+	}
 	free(keys);
+
 	LOG("Done");
-	// TODO: Handle duplicates by changing file name to .1, .2 etc.
 }
 
 size_t
@@ -775,6 +779,7 @@ load_agendafs_environment()
 	struct stat s;
 	if (stat(expanded_path, &s) == 0 && S_ISDIR(s.st_mode)) {
 		strlcpy(ICS_DIR, expanded_path, sizeof(ICS_DIR));
+		wordfree(&expanded);
 		return 0;
 	}
 
diff --git a/main.c b/main.c
@@ -448,7 +448,7 @@ main(int argc, char *argv[])
 
 	hashmap_free(entries_original_ics);
 	free_tree(fuse_tree_root);
-	LOG("Hashmap freed");
+	LOG("Hashmap and tree freed");
 
 	LOG("Regexp freed");
 	exit(ret);