#include <string.h>
#include "util.h"
-#include "sat_debug.h"
void *
-xmalloc(size_t len)
+sat_malloc(size_t len)
{
void *r = malloc(len ? len : 1);
if (r)
return r;
- sat_debug (ERROR, "Out of memory allocating %zu bytes!\n", len);
+ fprintf(stderr, "Out of memory allocating %zu bytes!\n", len);
exit(1);
}
void *
-xmalloc2(size_t num, size_t len)
+sat_malloc2(size_t num, size_t len)
{
if (len && (num * len) / len != num)
{
- sat_debug (ERROR, "Out of memory allocating %zu*%zu bytes!\n", num, len);
+ fprintf(stderr, "Out of memory allocating %zu*%zu bytes!\n", num, len);
exit(1);
}
- return xmalloc(num * len);
+ return sat_malloc(num * len);
}
void *
-xrealloc(void *old, size_t len)
+sat_realloc(void *old, size_t len)
{
if (old == 0)
old = malloc(len ? len : 1);
old = realloc(old, len ? len : 1);
if (old)
return old;
- sat_debug (ERROR, "Out of memory reallocating %zu bytes!\n", len);
+ fprintf(stderr, "Out of memory reallocating %zu bytes!\n", len);
exit(1);
}
void *
-xrealloc2(void *old, size_t num, size_t len)
+sat_realloc2(void *old, size_t num, size_t len)
{
if (len && (num * len) / len != num)
{
- sat_debug (ERROR, "Out of memory allocating %zu*%zu bytes!\n", num, len);
+ fprintf(stderr, "Out of memory allocating %zu*%zu bytes!\n", num, len);
exit(1);
}
- return xrealloc(old, num * len);
+ return sat_realloc(old, num * len);
}
void *
-xcalloc(size_t num, size_t len)
+sat_calloc(size_t num, size_t len)
{
void *r;
if (num == 0 || len == 0)
r = calloc(num, len);
if (r)
return r;
- sat_debug (ERROR, "Out of memory allocating %zu bytes!\n", num * len);
+ fprintf(stderr, "Out of memory allocating %zu bytes!\n", num * len);
exit(1);
}
void *
-xfree(void *mem)
+sat_free(void *mem)
{
if (mem)
free(mem);