Blob


1 #include <u.h>
2 #include <libc.h>
3 #include <bin.h>
4 #include <httpd.h>
6 /*
7 * memory allocators:
8 * h routines call canalloc; they should be used by everything else
9 * note this memory is wiped out at the start of each new request
10 * note: these routines probably shouldn't fatal.
11 */
12 char*
13 hstrdup(HConnect *c, char *s)
14 {
15 char *t;
16 int n;
18 n = strlen(s) + 1;
19 t = binalloc(&c->bin, n, 0);
20 if(t == nil)
21 sysfatal("out of memory");
22 memmove(t, s, n);
23 return t;
24 }
26 void*
27 halloc(HConnect *c, ulong n)
28 {
29 void *p;
31 p = binalloc(&c->bin, n, 1);
32 if(p == nil)
33 sysfatal("out of memory");
34 return p;
35 }