aboutsummaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
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);