1 #include <u.h> 2 #include <libc.h> 3 #include <draw.h> 4 #include <plumb.h> 5 #include "faces.h" 6 7 void* 8 emalloc(ulong sz) 9 { 10 void *v; 11 v = malloc(sz); 12 if(v == nil) { 13 fprint(2, "out of memory allocating %ld\n", sz); 14 exits("mem"); 15 } 16 memset(v, 0, sz); 17 return v; 18 } 19 20 void* 21 erealloc(void *v, ulong sz) 22 { 23 v = realloc(v, sz); 24 if(v == nil) { 25 fprint(2, "out of memory allocating %ld\n", sz); 26 exits("mem"); 27 } 28 return v; 29 } 30 31 char* 32 estrdup(char *s) 33 { 34 char *t; 35 if((t = strdup(s)) == nil) { 36 fprint(2, "out of memory in strdup(%.10s)\n", s); 37 exits("mem"); 38 } 39 return t; 40 } 41 42