diff options
| author | rsc <devnull@localhost> | 2003-11-23 18:19:35 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2003-11-23 18:19:35 +0000 |
| commit | 9df487d720a59bf8cb0dc4ccffc30ad8eb48256a (patch) | |
| tree | 9267054a81cefbb9a8ae3847ae0ddfc1567bd961 /src/libhttpd/alloc.c | |
| parent | b6afd33e2f23953f00c6fac6b5d45946a9113654 (diff) | |
add libhttpd
Diffstat (limited to 'src/libhttpd/alloc.c')
| -rw-r--r-- | src/libhttpd/alloc.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/libhttpd/alloc.c b/src/libhttpd/alloc.c new file mode 100644 index 00000000..1fdd46c6 --- /dev/null +++ b/src/libhttpd/alloc.c @@ -0,0 +1,35 @@ +#include <u.h> +#include <libc.h> +#include <bin.h> +#include <httpd.h> + +/* + * memory allocators: + * h routines call canalloc; they should be used by everything else + * note this memory is wiped out at the start of each new request + * note: these routines probably shouldn't fatal. + */ +char* +hstrdup(HConnect *c, char *s) +{ + char *t; + int n; + + n = strlen(s) + 1; + t = binalloc(&c->bin, n, 0); + if(t == nil) + sysfatal("out of memory"); + memmove(t, s, n); + return t; +} + +void* +halloc(HConnect *c, ulong n) +{ + void *p; + + p = binalloc(&c->bin, n, 1); + if(p == nil) + sysfatal("out of memory"); + return p; +} |