summaryrefslogtreecommitdiff
path: root/lib/exceptions.c
blob: 349e8a950925b7d2a4c576d535b38369025369ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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);
}