]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libhttpd/alloc.c
devproc: make sure writewatchpt() doesnt overflow the watchpoint array
[plan9front.git] / sys / src / libhttpd / alloc.c
1 #include <u.h>
2 #include <libc.h>
3 #include <bin.h>
4 #include <httpd.h>
5
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;
17
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 }
25
26 void*
27 halloc(HConnect *c, ulong n)
28 {
29         void *p;
30
31         p = binalloc(&c->bin, n, 1);
32         if(p == nil)
33                 sysfatal("out of memory");
34         return p;
35 }