equal
deleted
inserted
replaced
10 #include <unistd.h> |
10 #include <unistd.h> |
11 |
11 |
12 /* static */ |
12 /* static */ |
13 |
13 |
14 static void |
14 static void |
15 bad_malloc(unsigned int size) |
15 badmalloc(unsigned int size) |
16 { |
16 { |
17 eprint("fatal: could not malloc() %u bytes\n", size); |
17 eprint("fatal: could not malloc() %u bytes\n", size); |
18 } |
18 } |
19 |
19 |
20 /* extern */ |
20 /* extern */ |
23 emallocz(unsigned int size) |
23 emallocz(unsigned int size) |
24 { |
24 { |
25 void *res = calloc(1, size); |
25 void *res = calloc(1, size); |
26 |
26 |
27 if(!res) |
27 if(!res) |
28 bad_malloc(size); |
28 badmalloc(size); |
29 return res; |
29 return res; |
30 } |
30 } |
31 |
31 |
32 void |
32 void |
33 eprint(const char *errstr, ...) |
33 eprint(const char *errstr, ...) |
43 void * |
43 void * |
44 erealloc(void *ptr, unsigned int size) |
44 erealloc(void *ptr, unsigned int size) |
45 { |
45 { |
46 void *res = realloc(ptr, size); |
46 void *res = realloc(ptr, size); |
47 if(!res) |
47 if(!res) |
48 bad_malloc(size); |
48 badmalloc(size); |
49 return res; |
49 return res; |
50 } |
50 } |
51 |
51 |
52 void |
52 void |
53 spawn(Arg *arg) |
53 spawn(Arg *arg) |