X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/869431269586507d77909cbbe1f2640c40bb8a40..1d5a1da9f82f71e42e1609a4f91ef9020855be4b:/flist.c diff --git a/flist.c b/flist.c index 9c5f7372..dd4073db 100644 --- a/flist.c +++ b/flist.c @@ -279,13 +279,26 @@ static char *flist_dir; static void flist_expand(struct file_list *flist) { if (flist->count >= flist->malloced) { + size_t new_bytes; + void *new_ptr; + if (flist->malloced < 1000) flist->malloced += 1000; else flist->malloced *= 2; - flist->files = (struct file_struct **) - realloc(flist->files, - sizeof(flist->files[0]) * flist->malloced); + + new_bytes = sizeof(flist->files[0]) * flist->malloced; + + new_ptr = realloc(flist->files, new_bytes); + + if (verbose >= 2) { + rprintf(FINFO, RSYNC_NAME ": expand file_list to %.0f bytes, did%s move\n", + (double) new_bytes, + (new_ptr == flist->files) ? " not" : ""); + } + + flist->files = (struct file_struct **) new_ptr; + if (!flist->files) out_of_memory("flist_expand"); } @@ -1009,6 +1022,8 @@ struct file_list *recv_file_list(int f) for (flags = read_byte(f); flags; flags = read_byte(f)) { + int i = flist->count; + flist_expand(flist); receive_file_entry(&flist->files[i], flags, f);