Xinqi Bao's Git
99842e9c2032b16a095f34ca92fd06ebf02affe3
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
12 error(char *errstr
, ...) {
15 vfprintf(stderr
, errstr
, ap
);
21 bad_malloc(unsigned int size
)
23 fprintf(stderr
, "fatal: could not malloc() %d bytes\n",
29 emallocz(unsigned int size
)
31 void *res
= calloc(1, size
);
38 emalloc(unsigned int size
)
40 void *res
= malloc(size
);
47 erealloc(void *ptr
, unsigned int size
)
49 void *res
= realloc(ptr
, size
);
56 estrdup(const char *str
)
58 void *res
= strdup(str
);
60 bad_malloc(strlen(str
));
65 failed_assert(char *a
, char *file
, int line
)
67 fprintf(stderr
, "Assertion \"%s\" failed at %s:%d\n", a
, file
, line
);
72 swap(void **p1
, void **p2
)