From: Andrew Tridgell Date: Mon, 15 Dec 1997 17:29:51 +0000 (+0000) Subject: be a bit more friendly on systems that behave badly (consume lots of X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/f9c516202005d93005811c77eede7ee1f8267f61 be a bit more friendly on systems that behave badly (consume lots of ram) when you realloc() up by a small amount at a time --- diff --git a/flist.c b/flist.c index 2ec8318a..1ae8c341 100644 --- a/flist.c +++ b/flist.c @@ -316,12 +316,15 @@ static void send_file_name(int f,struct file_list *flist,char *fname) if (!file) return; if (flist->count >= flist->malloced) { - flist->malloced += 100; - flist->files = (struct file_struct *)realloc(flist->files, - sizeof(flist->files[0])* - flist->malloced); - if (!flist->files) - out_of_memory("send_file_name"); + if (flist->malloced < 100) + flist->malloced += 100; + else + flist->malloced *= 1.8; + flist->files = (struct file_struct *)realloc(flist->files, + sizeof(flist->files[0])* + flist->malloced); + if (!flist->files) + out_of_memory("send_file_name"); } if (strcmp(file->name,"/")) { @@ -504,12 +507,15 @@ struct file_list *recv_file_list(int f) int i = flist->count; if (i >= flist->malloced) { - flist->malloced += 100; - flist->files =(struct file_struct *)realloc(flist->files, - sizeof(flist->files[0])* - flist->malloced); - if (!flist->files) - goto oom; + if (flist->malloced < 100) + flist->malloced += 100; + else + flist->malloced *= 1.8; + flist->files =(struct file_struct *)realloc(flist->files, + sizeof(flist->files[0])* + flist->malloced); + if (!flist->files) + goto oom; } receive_file_entry(&flist->files[i],flags,f);