From 8212d25ba09a7fdf1938a1992022a0143d29e05b Mon Sep 17 00:00:00 2001 From: Pixel <> Date: Sun, 1 Apr 2001 12:36:50 +0000 Subject: Exceptions --- lib/exceptions.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lib/exceptions.c (limited to 'lib/exceptions.c') diff --git a/lib/exceptions.c b/lib/exceptions.c new file mode 100644 index 0000000..349e8a9 --- /dev/null +++ b/lib/exceptions.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include "config.h" +#include "exceptions.h" + +char * Estrdup(char * o) { + char * r; + + if (!(r = strdup(o))) { + exception(1, _("Out of memory.")); + } + return r; +} + +void * Emalloc(size_t s) { + void * r; + + if (!(r = malloc(s))) { + exception(1, _("Out of memory.")); + } + return r; +} + +void exception(int level, char *msg) +{ + fprintf(stderr, "%s\n", msg); + exit(level); +} -- cgit v1.2.3