Blob


1 #include <u.h>
2 #include <libc.h>
3 #include <auth.h>
4 #include <fcall.h>
5 #include <thread.h>
6 #include "9p.h"
8 void*
9 emalloc9p(ulong sz)
10 {
11 void *v;
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 }
22 void*
23 erealloc9p(void *v, ulong sz)
24 {
25 void *nv;
27 if((nv = realloc(v, sz)) == nil) {
28 fprint(2, "out of memory allocating %lud\n", sz);
29 exits("mem");
30 }
31 if(v == nil)
32 setmalloctag(nv, getcallerpc(&v));
33 setrealloctag(nv, getcallerpc(&v));
34 return nv;
35 }
37 char*
38 estrdup9p(char *s)
39 {
40 char *t;
42 if((t = strdup(s)) == nil) {
43 fprint(2, "out of memory in strdup(%.10s)\n", s);
44 exits("mem");
45 }
46 setmalloctag(t, getcallerpc(&s));
47 return t;
48 }