locations
[ccc.git] / util.h
1 #ifndef UTIL_H
2 #define UTIL_H
3
4 #include <stdarg.h>
5 #include <stdbool.h>
6
7 struct list {
8 void *el;
9 struct list *tail;
10 };
11 struct list *list_cons(void *el, struct list *tail);
12 void list_free(struct list *head, void (*freefun)(void *));
13 void **list_to_array(struct list *list, int *num, bool reverse);
14 int list_length(struct list *head);
15
16 void die(const char *msg, ...);
17 void pdie(const char *msg);
18
19 void pindent(int indent, FILE *out);
20 void safe_fprintf(FILE *out, const char *msg, ...);
21 void *safe_malloc(size_t size);
22 void *safe_strdup(const char *c);
23
24 #endif