From: Bastian Dehn Date: Sun, 12 Jan 2020 14:57:21 +0000 (+0100) Subject: fix: typdef of file_size_t struct X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=3eda86ad0436670b3d62ca62f71f4de3e3f4cbe8;p=discspan.git fix: typdef of file_size_t struct --- diff --git a/discspan.c b/discspan.c index 2b30cd8..6876f35 100644 --- a/discspan.c +++ b/discspan.c @@ -34,8 +34,8 @@ void printHumanReadSize(const char *output, unsigned long long splitgroesse) int cmpfunc(const void *filea, const void *fileb) { - unsigned long long a = ((const struct file_size*)filea)->fsize; - unsigned long long b = ((const struct file_size*)fileb)->fsize; + unsigned long long a = ((const file_size_t*)filea)->fsize; + unsigned long long b = ((const file_size_t*)fileb)->fsize; if (a < b) return 1; @@ -59,11 +59,11 @@ int cmpfunc(const void *filea, const void *fileb) * * @return Restlaenge des neuen Arrays */ -int splitter(struct file_size *input, const char *output, +int splitter(file_size_t *input, const char *output, unsigned long long splitgroesse, int length) { - struct file_size *rest = (struct file_size *) - malloc(length * sizeof(struct file_size)); + file_size_t *rest = (file_size_t *) + malloc(length * sizeof(file_size_t)); unsigned long long filesize = 0; int restcount = 0; @@ -86,9 +86,9 @@ int splitter(struct file_size *input, const char *output, printHumanReadSize(output, splitgroesse); if (restcount > 0) { - memcpy(input, rest, length * sizeof(struct file_size)); - input = (struct file_size *) - realloc(input, restcount * sizeof(struct file_size)); + memcpy(input, rest, length * sizeof(file_size_t)); + input = (file_size_t *) + realloc(input, restcount * sizeof(file_size_t)); } free(rest); @@ -140,9 +140,9 @@ int main(int argc, char *argv[]) } readArgument(argc, argv); - struct file_size *fs = read_input_file(input); + file_size_t *fs = read_input_file(input); - qsort(fs, (struct_array_length + 1), sizeof(struct file_size), cmpfunc); + qsort(fs, (struct_array_length + 1), sizeof(file_size_t), cmpfunc); char outname[strlen(output) + 3]; int num = 1; diff --git a/discspan.h b/discspan.h index fdcaf79..1614276 100644 --- a/discspan.h +++ b/discspan.h @@ -1,9 +1,9 @@ #ifndef _DISCSPAN_H #define _DISCSPAN_H -typedef struct file_size { +typedef struct { char name[255]; long long unsigned fsize; -} file_size; +} file_size_t; #endif diff --git a/readfile.c b/readfile.c index 66573a7..c857a72 100644 --- a/readfile.c +++ b/readfile.c @@ -36,7 +36,7 @@ int get_array_length(FILE *in) * * @return Arraylaenge */ -int fill_array_from_file(FILE *in, struct file_size *fs, +int fill_array_from_file(FILE *in, file_size_t *fs, const unsigned long long split) { FILE *ignore = NULL; @@ -74,17 +74,17 @@ int fill_array_from_file(FILE *in, struct file_size *fs, * * @return file_size struct array */ -file_size * read_input_file(const char *input) +file_size_t * read_input_file(const char *input) { FILE *in = fopen(input, "r"); struct_array_length = get_array_length(in); - struct file_size *fs = (struct file_size *) - malloc(struct_array_length * sizeof(struct file_size)); + file_size_t *fs = (file_size_t *) + malloc(struct_array_length * sizeof(file_size_t)); struct_array_length = fill_array_from_file(in, fs, split); - fs = (struct file_size *) - realloc(fs, struct_array_length * sizeof(struct file_size)); + fs = (file_size_t *) + realloc(fs, struct_array_length * sizeof(file_size_t)); fclose(in); diff --git a/readfile.h b/readfile.h index ec8dd5d..5fb4e08 100644 --- a/readfile.h +++ b/readfile.h @@ -5,6 +5,6 @@ #include "discspan.h" -file_size * read_input_file(const char *input); +file_size_t * read_input_file(const char *input); #endif