summaryrefslogtreecommitdiff
path: root/src/shared.c
blob: 5e58de0498bd7d03cd6dad1b2b5fbcc36783bf35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "shared.h"

#include <stdlib.h>
#include <errno.h>
#include <error.h>

void* xcalloc(size_t nmemb, size_t size) {
    void *mem = calloc(nmemb, size);

    if(mem == NULL) {
        #if defined ___VXGG___XCALLOC_EXIT_ON_ERROR___ && ___VXGG___XCALLOC_EXIT_ON_ERROR___ > 0
            error(1, errno, "<xcalloc> Could not allocate memory");
        #endif

        abort();
    }
    

    return mem;
}