diff options
author | Pixel <> | 2001-04-01 12:36:50 +0000 |
---|---|---|
committer | Pixel <> | 2001-04-01 12:36:50 +0000 |
commit | 8212d25ba09a7fdf1938a1992022a0143d29e05b (patch) | |
tree | bedd5f49afe9d2a74cdb7436ac1bce1151fe6d0e /lib/exceptions.c | |
parent | 4837528241a8f05ce2ca1fcdf35ea60b27728fb3 (diff) |
Exceptions
Diffstat (limited to 'lib/exceptions.c')
-rw-r--r-- | lib/exceptions.c | 29 |
1 files changed, 29 insertions, 0 deletions
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 <stdio.h> +#include <string.h> +#include <stdlib.h> +#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); +} |