Skip to content

Commit 9375a8c

Browse files
committed
Make my_alloc(NULL) use malloc instead of calloc.
1 parent 7f5c408 commit 9375a8c

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

ifuncs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ free_stat_x(stat_x *sx_p)
105105
static inline char *my_strdup(const char *str, const char *file, int line)
106106
{
107107
int len = strlen(str)+1;
108-
char *buf = my_alloc(do_malloc, len, 1, file, line);
108+
char *buf = my_alloc(NULL, len, 1, file, line);
109109
memcpy(buf, str, len);
110110
return buf;
111111
}

rsync.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -1324,15 +1324,15 @@ extern int errno;
13241324
/* handler for null strings in printf format */
13251325
#define NS(s) ((s)?(s):"<NULL>")
13261326

1327-
extern char *do_malloc;
1327+
extern char *do_calloc;
13281328

13291329
/* Convenient wrappers for malloc and realloc. Use them. */
1330-
#define new(type) ((type*)my_alloc(do_malloc, sizeof (type), 1, __FILE__, __LINE__))
1331-
#define new0(type) ((type*)my_alloc(NULL, sizeof (type), 1, __FILE__, __LINE__))
1330+
#define new(type) ((type*)my_alloc(NULL, sizeof (type), 1, __FILE__, __LINE__))
1331+
#define new0(type) ((type*)my_alloc(do_calloc, sizeof (type), 1, __FILE__, __LINE__))
13321332
#define realloc_buf(ptr, num) my_alloc((ptr), (num), 1, __FILE__, __LINE__)
13331333

1334-
#define new_array(type, num) ((type*)my_alloc(do_malloc, (num), sizeof (type), __FILE__, __LINE__))
1335-
#define new_array0(type, num) ((type*)my_alloc(NULL, (num), sizeof (type), __FILE__, __LINE__))
1334+
#define new_array(type, num) ((type*)my_alloc(NULL, (num), sizeof (type), __FILE__, __LINE__))
1335+
#define new_array0(type, num) ((type*)my_alloc(do_calloc, (num), sizeof (type), __FILE__, __LINE__))
13361336
#define realloc_array(ptr, type, num) ((type*)my_alloc((ptr), (num), sizeof (type), __FILE__, __LINE__))
13371337

13381338
#undef strdup

util2.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
extern size_t max_alloc;
2828

29-
char *do_malloc = "42";
29+
char *do_calloc = "42";
3030

3131
/**
3232
* Sleep for a specified number of milliseconds.
@@ -80,9 +80,9 @@ void *my_alloc(void *ptr, size_t num, size_t size, const char *file, int line)
8080
exit_cleanup(RERR_MALLOC);
8181
}
8282
if (!ptr)
83-
ptr = calloc(num, size);
84-
else if (ptr == do_malloc)
8583
ptr = malloc(num * size);
84+
else if (ptr == do_calloc)
85+
ptr = calloc(num, size);
8686
else
8787
ptr = realloc(ptr, num * size);
8888
if (!ptr && file)

0 commit comments

Comments
 (0)