comparison util.c @ 76:4bd49f404f10

proceeded with cleaning up, sorting functions, etc
author Anselm R. Garbe <garbeam@wmii.de>
date Sat, 15 Jul 2006 17:00:56 +0200
parents f08271b7cb20
children 052fe7498930
comparison
equal deleted inserted replaced
75:f08271b7cb20 76:4bd49f404f10
1 /* 1 /*
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details. 3 * See LICENSE file for license details.
4 */ 4 */
5 #include "dwm.h"
5 6
6 #include <stdarg.h> 7 #include <stdarg.h>
7 #include <stdio.h> 8 #include <stdio.h>
8 #include <stdlib.h> 9 #include <stdlib.h>
9 #include <sys/types.h>
10 #include <sys/wait.h> 10 #include <sys/wait.h>
11 #include <unistd.h> 11 #include <unistd.h>
12 12
13 #include "dwm.h" 13 /* static functions */
14
15 void
16 eprint(const char *errstr, ...) {
17 va_list ap;
18 va_start(ap, errstr);
19 vfprintf(stderr, errstr, ap);
20 va_end(ap);
21 exit(1);
22 }
23 14
24 static void 15 static void
25 bad_malloc(unsigned int size) 16 bad_malloc(unsigned int size)
26 { 17 {
27 fprintf(stderr, "fatal: could not malloc() %d bytes\n", 18 fprintf(stderr, "fatal: could not malloc() %d bytes\n",
28 (int) size); 19 (int) size);
29 exit(1); 20 exit(1);
30 } 21 }
31 22
23 /* extern functions */
24
32 void * 25 void *
33 emallocz(unsigned int size) 26 emallocz(unsigned int size)
34 { 27 {
35 void *res = calloc(1, size); 28 void *res = calloc(1, size);
36 if(!res) 29 if(!res)
37 bad_malloc(size); 30 bad_malloc(size);
38 return res; 31 return res;
32 }
33
34 void
35 eprint(const char *errstr, ...) {
36 va_list ap;
37 va_start(ap, errstr);
38 vfprintf(stderr, errstr, ap);
39 va_end(ap);
40 exit(1);
39 } 41 }
40 42
41 void 43 void
42 spawn(Arg *arg) 44 spawn(Arg *arg)
43 { 45 {