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