Mercurial > aewl
comparison util.c @ 461:9d23330a5268
removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Tue, 12 Sep 2006 10:57:28 +0200 |
parents | 44a55e6e46bf |
children | 740c4bfc3124 |
comparison
equal
deleted
inserted
replaced
460:ab4b08d49d24 | 461:9d23330a5268 |
---|---|
10 #include <unistd.h> | 10 #include <unistd.h> |
11 | 11 |
12 /* extern */ | 12 /* extern */ |
13 | 13 |
14 void * | 14 void * |
15 emallocz(unsigned int size) | 15 emallocz(unsigned int size) { |
16 { | |
17 void *res = calloc(1, size); | 16 void *res = calloc(1, size); |
18 | 17 |
19 if(!res) | 18 if(!res) |
20 eprint("fatal: could not malloc() %u bytes\n", size); | 19 eprint("fatal: could not malloc() %u bytes\n", size); |
21 return res; | 20 return res; |
22 } | 21 } |
23 | 22 |
24 void | 23 void |
25 eprint(const char *errstr, ...) | 24 eprint(const char *errstr, ...) { |
26 { | |
27 va_list ap; | 25 va_list ap; |
28 | 26 |
29 va_start(ap, errstr); | 27 va_start(ap, errstr); |
30 vfprintf(stderr, errstr, ap); | 28 vfprintf(stderr, errstr, ap); |
31 va_end(ap); | 29 va_end(ap); |
32 exit(EXIT_FAILURE); | 30 exit(EXIT_FAILURE); |
33 } | 31 } |
34 | 32 |
35 void * | 33 void * |
36 erealloc(void *ptr, unsigned int size) | 34 erealloc(void *ptr, unsigned int size) { |
37 { | |
38 void *res = realloc(ptr, size); | 35 void *res = realloc(ptr, size); |
39 if(!res) | 36 if(!res) |
40 eprint("fatal: could not malloc() %u bytes\n", size); | 37 eprint("fatal: could not malloc() %u bytes\n", size); |
41 return res; | 38 return res; |
42 } | 39 } |
43 | 40 |
44 void | 41 void |
45 spawn(Arg *arg) | 42 spawn(Arg *arg) { |
46 { | |
47 static char *shell = NULL; | 43 static char *shell = NULL; |
48 | 44 |
49 if(!shell && !(shell = getenv("SHELL"))) | 45 if(!shell && !(shell = getenv("SHELL"))) |
50 shell = "/bin/sh"; | 46 shell = "/bin/sh"; |
51 | 47 |