From: Bastian Dehn Date: Sun, 24 Dec 2017 11:44:06 +0000 (+0100) Subject: fix: relloc bug of restfiles X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=9d96fef1bc209d778b19a28801119fc5a481c5bd;p=discspan.git fix: relloc bug of restfiles --- 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);