agendafs
A filesystem for your calendar.
git clone git://mccd.space/agendafscommit 19390f855dfb4c23b532ac03e1e4d163d0873760
parent 1c1a7b02588e34e81036a31fc12e8f1bac9bd3d8
Author: Marc Coquand <marc@coquand.email>
Date: Sun, 1 Jun 2025 18:47:22 +0100
Updates
Diffstat:
4 files changed, 69 insertions(+), 2 deletions(-)
diff --git a/.clang-format b/.clang-format
@@ -3,3 +3,4 @@ UseTab: Always
IndentWidth: 8
TabWidth: 8
BreakBeforeBraces: Stroustrup
+AlwaysBreakAfterReturnType: All
diff --git a/Makefile b/Makefile
@@ -6,10 +6,10 @@ LIBS = `pkg-config fuse3 --cflags --libs`
all: caldavfs
caldavfs: main.c hashmap.c
- $(CC) $(CFLAGS) main.c hashmap.c -o caldavfs $(LIBS)
+ $(CC) $(CFLAGS) main.c util.c hashmap.c -o caldavfs $(LIBS)
debug: main.c hashmap.c
- $(CC) $(CFLAGS_DEBUG) $(DEBUG_FLAGS) main.c hashmap.c -o caldavfs-debug $(LIBS)
+ $(CC) $(CFLAGS_DEBUG) $(DEBUG_FLAGS) main.c util.c hashmap.c -o caldavfs-debug $(LIBS)
clean:
rm -f caldavfs caldavfs-debug
diff --git a/util.c b/util.c
@@ -0,0 +1,55 @@
+// Copyright © 2019-2024 Michael Forney
+// util.c from cproc
+#include <assert.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void *
+xmalloc(size_t len)
+{
+ void *buf;
+
+ buf = malloc(len);
+ if (!buf && len)
+ exit(1);
+
+ return buf;
+}
+
+void *
+xcalloc(size_t memb, size_t s)
+{
+ void *buf;
+
+ buf = calloc(memb, s);
+ if (!buf)
+ exit(1);
+
+ return buf;
+}
+
+void *
+reallocarray(void *buf, size_t n, size_t m)
+{
+ if (n > 0 && SIZE_MAX / n < m) {
+ errno = ENOMEM;
+ return NULL;
+ }
+ return realloc(buf, n * m);
+}
+
+void *
+xreallocarray(void *buf, size_t n, size_t m)
+{
+ buf = reallocarray(buf, n, m);
+ if (!buf && n && m)
+ exit(1);
+
+ return buf;
+}
+
diff --git a/util.h b/util.h
@@ -0,0 +1,11 @@
+#include <stdlib.h>
+
+void *
+reallocarray(void *, size_t, size_t);
+void *
+xreallocarray(void *, size_t, size_t);
+void *
+xmalloc(size_t);
+void *
+xcalloc(size_t, size_t);
+