From 9d96fef1bc209d778b19a28801119fc5a481c5bd Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 24 Dec 2017 12:44:06 +0100 Subject: [PATCH] fix: relloc bug of restfiles --- discspan.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/discspan.c b/discspan.c index f16cb35..f7881fa 100644 --- a/discspan.c +++ b/discspan.c @@ -139,14 +139,17 @@ int splitter(struct file_size *input, const char *output, } } fclose(out); - restcount--; printHumanReadSize(output, splitgroesse); - if(restcount > 0) + if(restcount > 0) { memcpy(input, rest, length * sizeof(struct file_size)); + input = (struct file_size *) + realloc(input, restcount * sizeof(struct file_size)); + } free(rest); + restcount--; return restcount; } @@ -212,8 +215,6 @@ int main(int argc, char *argv[]) while(s_length > 0) { sprintf(outname, "%s%03d", output, num++); s_length = splitter(fs, outname, split, s_length); - fs = (struct file_size *) - realloc(fs, s_length * sizeof(struct file_size)); } free(fs); -- 2.39.5