Imported Upstream version 1.7.1
[platform/upstream/edje.git] / src / bin / edje_cc_mem.c
1 #ifdef HAVE_CONFIG_H
2 # include "config.h"
3 #endif
4
5 #include <string.h>
6 #include <errno.h>
7
8 #include "edje_cc.h"
9
10 void *
11 mem_alloc(size_t size)
12 {
13    void *mem;
14
15    mem = calloc(1, size);
16    if (mem) return mem;
17    ERR("%s:%i memory allocation of %zu bytes failed. %s",
18        file_in, line, size, strerror(errno));
19    exit(-1);
20    return NULL;
21 }
22
23 char *
24 mem_strdup(const char *s)
25 {
26    void *str;
27
28    str = strdup(s);
29    if (str) return str;
30    ERR("%s:%i memory allocation of %zu bytes failed. %s. string being duplicated: \"%s\"",
31        file_in, line, strlen(s) + 1, strerror(errno), s);
32    exit(-1);
33    return NULL;
34 }