blob: 1c1804b8e6f9f68830690ddbd242e22b77556140 (
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
29
30
|
#ifndef FVM_UTILS_H_
#define FVM_UTILS_H_
#include <stdlib.h>
struct allocator;
typedef struct allocator allocator;
struct result {
void *value;
const char* errmsg;
};
typedef struct result result;
#define unwrap(x__) ({ \
struct result res__ = (x__); \
if (res__.errmsg != NULL) return res__; \
res__.value;})
result ok(void *value);
result err(const char *errmsg);
allocator* new_allocator();
void delete_allocator(allocator* allocator);
void* allocate(allocator* allocator, size_t size);
char* safe_sprintf(allocator* alct, const char* format, ...);
#endif // FVM_UTILS_H_
|