From b330c942b468ab82fd8853590145187e859258cb Mon Sep 17 00:00:00 2001 From: rsc Date: Mon, 31 Oct 2005 14:47:39 +0000 Subject: initial faces (John Cummings) --- src/cmd/faces/util.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/cmd/faces/util.c (limited to 'src/cmd/faces/util.c') diff --git a/src/cmd/faces/util.c b/src/cmd/faces/util.c new file mode 100644 index 00000000..22f57549 --- /dev/null +++ b/src/cmd/faces/util.c @@ -0,0 +1,42 @@ +#include +#include +#include +#include +#include <9pclient.h> +#include "faces.h" + +void* +emalloc(ulong sz) +{ + void *v; + v = malloc(sz); + if(v == nil) { + fprint(2, "out of memory allocating %ld\n", sz); + exits("mem"); + } + memset(v, 0, sz); + return v; +} + +void* +erealloc(void *v, ulong sz) +{ + v = realloc(v, sz); + if(v == nil) { + fprint(2, "out of memory allocating %ld\n", sz); + exits("mem"); + } + return v; +} + +char* +estrdup(char *s) +{ + char *t; + if((t = strdup(s)) == nil) { + fprint(2, "out of memory in strdup(%.10s)\n", s); + exits("mem"); + } + return t; +} + -- cgit v1.2.3