… | |
… | |
20 | static void *xmalloc(const size_t size) |
20 | static void *xmalloc(const size_t size) |
21 | { |
21 | { |
22 | void *ret = malloc(size); |
22 | void *ret = malloc(size); |
23 | |
23 | |
24 | if (!ret && size) { |
24 | if (!ret && size) { |
25 | fprintf(stderr, "Error: cannot allocate %zu bytes", size); |
25 | fprintf(stderr, "%s: error: cannot allocate %zu bytes", program_invocation_short_name, size); |
26 | exit(XALLOC_EXIT_CODE); |
26 | exit(XALLOC_EXIT_CODE); |
27 | } |
27 | } |
28 | return ret; |
28 | return ret; |
29 | } |
29 | } |
30 | |
30 | |
31 | static void *xrealloc(void *ptr, const size_t size) |
31 | static void *xrealloc(void *ptr, const size_t size) |
32 | { |
32 | { |
33 | void *ret = realloc(ptr, size); |
33 | void *ret = realloc(ptr, size); |
34 | |
34 | |
35 | if (!ret && size) |
35 | if (!ret && size) |
36 | fprintf(stderr, "Error: cannot allocate %zu bytes", size); |
36 | fprintf(stderr, "%s: Error: cannot allocate %zu bytes", program_invocation_short_name, size); |
37 | return ret; |
37 | return ret; |
38 | } |
38 | } |
39 | |
39 | |
40 | #endif |
40 | #endif |