diff options
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 34 |
1 files changed, 0 insertions, 34 deletions
@@ -1,34 +0,0 @@ | |||
1 | /* See LICENSE file for copyright and license details. */ | ||
2 | #include "dmenu.h" | ||
3 | #include <stdarg.h> | ||
4 | #include <stdio.h> | ||
5 | #include <stdlib.h> | ||
6 | #include <string.h> | ||
7 | |||
8 | void * | ||
9 | emalloc(unsigned int size) { | ||
10 | void *res = malloc(size); | ||
11 | |||
12 | if(!res) | ||
13 | eprint("fatal: could not malloc() %u bytes\n", size); | ||
14 | return res; | ||
15 | } | ||
16 | |||
17 | void | ||
18 | eprint(const char *errstr, ...) { | ||
19 | va_list ap; | ||
20 | |||
21 | va_start(ap, errstr); | ||
22 | vfprintf(stderr, errstr, ap); | ||
23 | va_end(ap); | ||
24 | exit(EXIT_FAILURE); | ||
25 | } | ||
26 | |||
27 | char * | ||
28 | estrdup(const char *str) { | ||
29 | void *res = strdup(str); | ||
30 | |||
31 | if(!res) | ||
32 | eprint("fatal: could not malloc() %u bytes\n", strlen(str)); | ||
33 | return res; | ||
34 | } | ||