From f9c516202005d93005811c77eede7ee1f8267f61 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 Dec 1997 17:29:51 +0000 Subject: [PATCH] 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 --- flist.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) 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); -- 2.34.1