static inline char *my_strdup(const char *str, const char *file, int line)
{
int len = strlen(str)+1;
- char *buf = my_alloc(do_malloc, len, 1, file, line);
+ char *buf = my_alloc(NULL, len, 1, file, line);
memcpy(buf, str, len);
return buf;
}
/* handler for null strings in printf format */
#define NS(s) ((s)?(s):"<NULL>")
-extern char *do_malloc;
+extern char *do_calloc;
/* Convenient wrappers for malloc and realloc. Use them. */
-#define new(type) ((type*)my_alloc(do_malloc, sizeof (type), 1, __FILE__, __LINE__))
-#define new0(type) ((type*)my_alloc(NULL, sizeof (type), 1, __FILE__, __LINE__))
+#define new(type) ((type*)my_alloc(NULL, sizeof (type), 1, __FILE__, __LINE__))
+#define new0(type) ((type*)my_alloc(do_calloc, sizeof (type), 1, __FILE__, __LINE__))
#define realloc_buf(ptr, num) my_alloc((ptr), (num), 1, __FILE__, __LINE__)
-#define new_array(type, num) ((type*)my_alloc(do_malloc, (num), sizeof (type), __FILE__, __LINE__))
-#define new_array0(type, num) ((type*)my_alloc(NULL, (num), sizeof (type), __FILE__, __LINE__))
+#define new_array(type, num) ((type*)my_alloc(NULL, (num), sizeof (type), __FILE__, __LINE__))
+#define new_array0(type, num) ((type*)my_alloc(do_calloc, (num), sizeof (type), __FILE__, __LINE__))
#define realloc_array(ptr, type, num) ((type*)my_alloc((ptr), (num), sizeof (type), __FILE__, __LINE__))
#undef strdup
extern size_t max_alloc;
-char *do_malloc = "42";
+char *do_calloc = "42";
/**
* Sleep for a specified number of milliseconds.
exit_cleanup(RERR_MALLOC);
}
if (!ptr)
- ptr = calloc(num, size);
- else if (ptr == do_malloc)
ptr = malloc(num * size);
+ else if (ptr == do_calloc)
+ ptr = calloc(num, size);
else
ptr = realloc(ptr, num * size);
if (!ptr && file)