agendafs

A filesystem for your calendar.

git clone git://mccd.space/agendafs
commit dd6e632869cd65bd058a0fd71023bb5fdb246a5f
parent ca0f85fa935595c580f5bbedb12c667cc8741eb6
Author: Marc Coquand <marc@coquand.email>
Date:   Sun, 13 Jul 2025 22:31:17 +0200

bugfixes

Diffstat:
Mjournal_entry.c | 8++++----
Mpath.c | 5++---
Mpath.h | 2+-
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/journal_entry.c b/journal_entry.c
@@ -195,10 +195,9 @@ get_node_by_path(const char *path)
 		return fuse_tree_root;
 	}
 
-	char **segments = NULL;
+	char *segments[255];
 	size_t count = split_path(path, segments);
-	if (!segments)
-		return fuse_tree_root;
+
 	LOG("Segments are defined");
 
 	struct tree_node *current = fuse_tree_root;
@@ -1126,12 +1125,13 @@ create_entry_from_fuse(const char *fuse_path)
 	char *new_basename = strrchr(fuse_path, '/');
 	new_basename++;
 
-	path *without_extension = remove_file_extension(new_basename);
+	path *without_extension = without_file_extension(new_basename);
 
 	struct journal_entry *new_entry =
 	    xcalloc(1, sizeof(struct journal_entry));
 	icalcomponent *vjournal_component =
 	    create_vjournal_entry(without_extension);
+	free(without_extension);
 
 	new_entry->component = vjournal_component;
 	new_entry->filename = strdup(new_basename);
diff --git a/path.c b/path.c
@@ -5,7 +5,7 @@
 #include <string.h>
 
 path *
-remove_file_extension(const path *p)
+without_file_extension(const path *p)
 {
 	char *cpy = xstrdup(p);
 	char *last_dot = strrchr(cpy, '.');
@@ -24,7 +24,6 @@ free_segments(char **segments, size_t count)
 {
 	for (size_t i = 0; i < count; ++i)
 		free(segments[i]);
-	free(segments);
 }
 
 path *
@@ -82,7 +81,7 @@ split_path(const path *p, char **segments)
 	char *saveptr;
 	segment = strtok_r(path_copy, "/", &saveptr);
 	while (segment) {
-		segments[count++] = strdup(segment);
+		segments[count++] = xstrdup(segment);
 		segment = strtok_r(NULL, "/", &saveptr);
 	}
 	free(path_copy);
diff --git a/path.h b/path.h
@@ -8,7 +8,7 @@
 typedef char path;
 
 path *
-remove_file_extension(const path *);
+without_file_extension(const path *);
 
 void
 free_segments(path **, size_t);