From e5888a1ffdae813d7575f5fb02275c6bb07e5199 Mon Sep 17 00:00:00 2001 From: Taru Karttunen Date: Wed, 30 Mar 2011 15:46:40 +0300 Subject: Import sources from 2011-03-30 iso image --- sys/src/libhttpd/alloc.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 sys/src/libhttpd/alloc.c (limited to 'sys/src/libhttpd/alloc.c') diff --git a/sys/src/libhttpd/alloc.c b/sys/src/libhttpd/alloc.c new file mode 100755 index 000000000..1fdd46c66 --- /dev/null +++ b/sys/src/libhttpd/alloc.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include + +/* + * 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; +} -- cgit v1.2.3