2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
16 sat_malloc(size_t len)
18 void *r = malloc(len ? len : 1);
21 fprintf(stderr, "Out of memory allocating %zu bytes!\n", len);
26 sat_malloc2(size_t num, size_t len)
28 if (len && (num * len) / len != num)
30 fprintf(stderr, "Out of memory allocating %zu*%zu bytes!\n", num, len);
33 return sat_malloc(num * len);
37 sat_realloc(void *old, size_t len)
40 old = malloc(len ? len : 1);
42 old = realloc(old, len ? len : 1);
45 fprintf(stderr, "Out of memory reallocating %zu bytes!\n", len);
50 sat_realloc2(void *old, size_t num, size_t len)
52 if (len && (num * len) / len != num)
54 fprintf(stderr, "Out of memory allocating %zu*%zu bytes!\n", num, len);
57 return sat_realloc(old, num * len);
61 sat_calloc(size_t num, size_t len)
64 if (num == 0 || len == 0)
70 fprintf(stderr, "Out of memory allocating %zu bytes!\n", num * len);