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 8 void* 9 emalloc9p(ulong sz) 10 { 11 void *v; 12 13 if((v = malloc(sz)) == nil) { 14 fprint(2, "out of memory allocating %lud\n", sz); 15 exits("mem"); 16 } 17 memset(v, 0, sz); 18 setmalloctag(v, getcallerpc(&sz)); 19 return v; 20 } 21 22 void* 23 erealloc9p(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 setrealloctag(v, getcallerpc(&v)); 30 return v; 31 } 32 33 char* 34 estrdup9p(char *s) 35 { 36 char *t; 37 38 if((t = strdup(s)) == nil) { 39 fprint(2, "out of memory in strdup(%.10s)\n", s); 40 exits("mem"); 41 } 42 setmalloctag(t, getcallerpc(&s)); 43 return t; 44 } 45 46