diff --git a/Sorting/9Ex/a.out b/Sorting/9Ex/a.out new file mode 100644 index 0000000..9c303f2 Binary files /dev/null and b/Sorting/9Ex/a.out differ diff --git a/Sorting/9Ex/leak.out b/Sorting/9Ex/leak.out new file mode 100644 index 0000000..cb19c02 --- /dev/null +++ b/Sorting/9Ex/leak.out @@ -0,0 +1,12 @@ +# LeakReport +# from new @ | size # Pointer Addr +L 0x402b51 64 # 0xf17920 +L 0x4026ba 80000000 # 0x7ff8765bc010 +L 0x4026ba 48 # 0xf179b0 +L 0x402cc9 80000000 # 0x7ff87fe54010 +L 0x4026a5 80000000 # 0x7ff87b208010 +L 0x4026a5 48 # 0xf17970 +# total allocation requests: 8 ; max. mem used 234375 kBytes +# leak 240000160 Bytes :-( +# .. that is 234375 kByte!! A lot .. +WORK TIME - 00:00:14.06 diff --git a/Sorting/9Ex/main.c b/Sorting/9Ex/main.c index 86a2ff6..e649462 100644 --- a/Sorting/9Ex/main.c +++ b/Sorting/9Ex/main.c @@ -3,7 +3,7 @@ #include "tools.h" #include -int main() { +int main(void) { FILE * file = getFile(); double * array; int length; @@ -11,7 +11,7 @@ int main() { if (file == NULL) return -1; array = getArray(file); if (array == NULL) return -2; - length = (int)array[0]; + length = (int)array[0] - 1; array = &array[1]; printArray(array, length); diff --git a/Sorting/9Ex/makefile b/Sorting/9Ex/makefile index cec5611..f750d0b 100644 --- a/Sorting/9Ex/makefile +++ b/Sorting/9Ex/makefile @@ -1,6 +1,6 @@ all: main.o seagwithsob.o tools.o - gcc main.o seagwithsob.o tools.o && del *.o - a.exe + gcc main.o seagwithsob.o tools.o && rm *.o + ./a.out main.o: main.c gcc -c main.c diff --git a/Sorting/9Ex/seagwithsob.c b/Sorting/9Ex/seagwithsob.c index 4943dea..8012070 100644 --- a/Sorting/9Ex/seagwithsob.c +++ b/Sorting/9Ex/seagwithsob.c @@ -1,8 +1,9 @@ #include "seagwithsob.h" void sort(double * array, int length) { - double zero[length]; - double unit[length]; + double * zero = (double *)malloc(length * sizeof(double)); + double * unit = (double *)malloc(length * sizeof(double)); + int index, timer = -clock(); for (int j = 0; j < 63; ++j) { diff --git a/Sorting/9Ex/seagwithsob.h b/Sorting/9Ex/seagwithsob.h index f23efc2..e2f1ab5 100644 --- a/Sorting/9Ex/seagwithsob.h +++ b/Sorting/9Ex/seagwithsob.h @@ -2,6 +2,7 @@ #define SEAGWITHSOB #include +#include #include #include diff --git a/Sorting/9Ex/tools.c b/Sorting/9Ex/tools.c index f9a60a3..edd79c2 100644 --- a/Sorting/9Ex/tools.c +++ b/Sorting/9Ex/tools.c @@ -1,10 +1,10 @@ #include "tools.h" -FILE * getFile() { +FILE * getFile(void) { char filename[50]; printf("Enter file name: "); - if (scanf("%s", &filename) == 1) { + if (scanf("%s", filename) == 1) { FILE * file = fopen(filename, "r"); if (file == NULL) { printf("Error file!\n)"); @@ -19,7 +19,6 @@ FILE * getFile() { } double * getArray(FILE * file) { - char filename[50]; int i, size = 2; double * array = NULL; double current; @@ -53,7 +52,7 @@ bool orderliness(double * array, int length) { return true; } -void randomArray() { +void randomArray(void) { int length; printf("Enter length of array: "); diff --git a/Sorting/9Ex/tools.h b/Sorting/9Ex/tools.h index 1830ada..bc80a94 100644 --- a/Sorting/9Ex/tools.h +++ b/Sorting/9Ex/tools.h @@ -10,10 +10,10 @@ #define exp -1.e-6 -FILE * getFile(); +FILE * getFile(void); double * getArray(FILE * file); bool orderliness(double * array, int length); -void randomArray(); +void randomArray(void); void generate(double * array, int length); void printArray(double * array, int length);