blob: 8bc76f84b426e101dadcd982d56286ea4557282e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#ifndef FVM_UTILS_H_
#define FVM_UTILS_H_
#include <stdlib.h>
struct allocator;
struct result {
void *value;
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);
void* allocate(struct allocator * allocator, size_t size);
char* safe_sprintf(struct allocator *alct, const char* format, ...);
#endif // FVM_UTILS_H_
|