blob: 1fdd46c6694508803452c7d9d2e3a58b6d5f50d7 [file] [log] [blame]
rsc9df487d2003-11-23 18:19:35 +00001#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 */
12char*
13hstrdup(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
26void*
27halloc(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}