11 void *r = malloc(len ? len : 1);
14 fprintf(stderr, "Out of memory allocating %zu bytes!\n", len);
19 xmalloc2(size_t num, size_t len)
21 if (len && (num * len) / len != num)
23 fprintf(stderr, "Out of memory allocating %zu*%zu bytes!\n", num, len);
26 return xmalloc(num * len);
30 xrealloc(void *old, size_t len)
33 old = malloc(len ? len : 1);
35 old = realloc(old, len ? len : 1);
38 fprintf(stderr, "Out of memory reallocating %zu bytes!\n", len);
43 xrealloc2(void *old, size_t num, size_t len)
45 if (len && (num * len) / len != num)
47 fprintf(stderr, "Out of memory allocating %zu*%zu bytes!\n", num, len);
50 return xrealloc(old, num * len);
54 xcalloc(size_t num, size_t len)
57 if (num == 0 || len == 0)
63 fprintf(stderr, "Out of memory allocating %zu bytes!\n", num * len);