mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-05-11 00:14:00 -04:00
Tweak alloc args to size_t w/proper realloc order.
This commit is contained in:
2
rsync.h
2
rsync.h
@@ -1267,7 +1267,7 @@ extern int errno;
|
||||
#define new0(type) ((type*)calloc(1, sizeof (type)))
|
||||
#define new_array(type, num) ((type*)_new_array((num), sizeof (type), 0))
|
||||
#define new_array0(type, num) ((type*)_new_array((num), sizeof (type), 1))
|
||||
#define realloc_array(ptr, type, num) ((type*)_realloc_array((ptr), sizeof(type), (num)))
|
||||
#define realloc_array(ptr, type, num) ((type*)_realloc_array((ptr), (num), sizeof (type)))
|
||||
|
||||
/* use magic gcc attributes to catch format errors */
|
||||
void rprintf(enum logcode , const char *, ...)
|
||||
|
||||
2
util.c
2
util.c
@@ -1655,7 +1655,7 @@ void *expand_item_list(item_list *lp, size_t item_size, const char *desc, int in
|
||||
if (new_size <= lp->malloced)
|
||||
overflow_exit("expand_item_list");
|
||||
/* Using _realloc_array() lets us pass the size, not a type. */
|
||||
new_ptr = _realloc_array(lp->items, item_size, new_size);
|
||||
new_ptr = _realloc_array(lp->items, new_size, item_size);
|
||||
if (DEBUG_GTE(FLIST, 3)) {
|
||||
rprintf(FINFO, "[%s] expand %s to %s bytes, did%s move\n",
|
||||
who_am_i(), desc, big_num(new_size * item_size),
|
||||
|
||||
4
util2.c
4
util2.c
@@ -69,14 +69,14 @@ int msleep(int t)
|
||||
|
||||
#define MALLOC_MAX 0x40000000
|
||||
|
||||
void *_new_array(unsigned long num, unsigned int size, int use_calloc)
|
||||
void *_new_array(size_t num, size_t size, int use_calloc)
|
||||
{
|
||||
if (num >= MALLOC_MAX/size)
|
||||
return NULL;
|
||||
return use_calloc ? calloc(num, size) : malloc(num * size);
|
||||
}
|
||||
|
||||
void *_realloc_array(void *ptr, unsigned int size, size_t num)
|
||||
void *_realloc_array(void *ptr, size_t num, size_t size)
|
||||
{
|
||||
if (num >= MALLOC_MAX/size)
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user