From: Andrew Tridgell Date: Thu, 28 May 1998 06:40:25 +0000 (+0000) Subject: use Realloc instead of realloc X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/fe8c0a9824bf990ae3ff692d25105dd2c9f0ebf4 use Realloc instead of realloc --- diff --git a/exclude.c b/exclude.c index ab01234c..d25adb34 100644 --- a/exclude.c +++ b/exclude.c @@ -146,11 +146,7 @@ void add_exclude_list(char *pattern,struct exclude_struct ***list, int include) return; } - if (!*list) { - *list = (struct exclude_struct **)malloc(sizeof(struct exclude_struct *)*2); - } else { - *list = (struct exclude_struct **)realloc(*list,sizeof(struct exclude_struct *)*(len+2)); - } + *list = (struct exclude_struct **)Realloc(*list,sizeof(struct exclude_struct *)*(len+2)); if (!*list || !((*list)[len] = make_exclude(pattern, include))) out_of_memory("add_exclude"); diff --git a/io.c b/io.c index e9a66a48..8eb62c38 100644 --- a/io.c +++ b/io.c @@ -223,10 +223,7 @@ static void read_check(int f) if (n > (read_buffer_size - read_buffer_len)) { read_buffer_size += n; - if (!read_buffer) - read_buffer = (char *)malloc(read_buffer_size); - else - read_buffer = (char *)realloc(read_buffer,read_buffer_size); + read_buffer = (char *)Realloc(read_buffer,read_buffer_size); if (!read_buffer) out_of_memory("read check"); read_buffer_p = read_buffer; } diff --git a/loadparm.c b/loadparm.c index 0ddbc61a..b17c3877 100644 --- a/loadparm.c +++ b/loadparm.c @@ -366,12 +366,7 @@ static int add_a_service(service *pservice, char *name) i = iNumServices; - if (ServicePtrs) { - ServicePtrs = (service **)realloc(ServicePtrs, - sizeof(service *)*num_to_alloc); - } else { - ServicePtrs = (service **)malloc(sizeof(service *)*num_to_alloc); - } + ServicePtrs = (service **)Realloc(ServicePtrs,sizeof(service *)*num_to_alloc); if (ServicePtrs) pSERVICE(iNumServices) = (service *)malloc(sizeof(service)); diff --git a/params.c b/params.c index be019308..b1093c3c 100644 --- a/params.c +++ b/params.c @@ -77,7 +77,6 @@ #define BOOL int #define False 0 #define True 1 -#define Realloc realloc /* -------------------------------------------------------------------------- ** * Constants... diff --git a/rsync.c b/rsync.c index f41029be..b61128b1 100644 --- a/rsync.c +++ b/rsync.c @@ -638,11 +638,7 @@ static void add_delete_entry(struct file_struct *file) { if (dlist_len == dlist_alloc_len) { dlist_alloc_len += 1024; - if (!delete_list) { - delete_list = (struct delete_list *)malloc(sizeof(delete_list[0])*dlist_alloc_len); - } else { - delete_list = (struct delete_list *)realloc(delete_list, sizeof(delete_list[0])*dlist_alloc_len); - } + delete_list = (struct delete_list *)Realloc(delete_list, sizeof(delete_list[0])*dlist_alloc_len); if (!delete_list) out_of_memory("add_delete_entry"); } diff --git a/util.c b/util.c index b95e0b45..6470bf97 100644 --- a/util.c +++ b/util.c @@ -553,3 +553,9 @@ int slprintf(char *str, int n, char *format, ...) return ret; } + +void *Realloc(void *p, int size) +{ + if (!p) return (void *)malloc(size); + return (void *)realloc(p, size); +}