diff options
Diffstat (limited to 'libraries/edje/src/bin/edje_cc_mem.c')
-rw-r--r-- | libraries/edje/src/bin/edje_cc_mem.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/libraries/edje/src/bin/edje_cc_mem.c b/libraries/edje/src/bin/edje_cc_mem.c new file mode 100644 index 0000000..7c1a5c9 --- /dev/null +++ b/libraries/edje/src/bin/edje_cc_mem.c | |||
@@ -0,0 +1,40 @@ | |||
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 | #ifdef _WIN32 | ||
11 | # define FMT_SIZE_T "%Iu" | ||
12 | #else | ||
13 | # define FMT_SIZE_T "%zu" | ||
14 | #endif | ||
15 | |||
16 | void * | ||
17 | mem_alloc(size_t size) | ||
18 | { | ||
19 | void *mem; | ||
20 | |||
21 | mem = calloc(1, size); | ||
22 | if (mem) return mem; | ||
23 | ERR("%s: Error. %s:%i memory allocation of " FMT_SIZE_T " bytes failed. %s", | ||
24 | progname, file_in, line, size, strerror(errno)); | ||
25 | exit(-1); | ||
26 | return NULL; | ||
27 | } | ||
28 | |||
29 | char * | ||
30 | mem_strdup(const char *s) | ||
31 | { | ||
32 | void *str; | ||
33 | |||
34 | str = strdup(s); | ||
35 | if (str) return str; | ||
36 | ERR("%s: Error. %s:%i memory allocation of " FMT_SIZE_T " bytes failed. %s. string being duplicated: \"%s\"", | ||
37 | progname, file_in, line, strlen(s) + 1, strerror(errno), s); | ||
38 | exit(-1); | ||
39 | return NULL; | ||
40 | } | ||