aboutsummaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-03-25 14:03:10 +0800
committerMistivia <i@mistivia.com>2025-03-25 14:03:10 +0800
commitd1195499338ba4b6536f8a6a56564622eb07469f (patch)
tree5b24b8355a82ae0207c4b6910348adfbbd52c8ef /src/utils.h
parentfb7664e087cb1afb64aae2128365f703beb30b57 (diff)
better error handling
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h
index 5f7c0ff..8bc76f8 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -10,6 +10,14 @@ struct result {
const char* errmsg;
};
+#define unwrap(x__) ({ \
+ struct result res__ = (x__); \
+ if (res__.errmsg != NULL) return res__; \
+ res__.value;})
+
+struct result ok(void *value);
+struct result err(const char *errmsg);
+
struct allocator * new_allocator();
void delete_allocator(struct allocator * allocator);