diff --git a/sk1a.zip b/sk1a.zip deleted file mode 100644 index 098b10f..0000000 Binary files a/sk1a.zip and /dev/null differ diff --git a/sk1a/readme.md b/sk1a/readme.md index 021a40a..f656121 100644 --- a/sk1a/readme.md +++ b/sk1a/readme.md @@ -4,19 +4,19 @@ #include int issafe(char* maze, int x, int y, int size) { -if ((x >= 0 && x < size) && (y >= 0 && y < size) && (maze[x * size + y] == ' ')){ +if ((x >= 0 && x < size) && (y >= 0 && y < size) && (maze[x * size + y] == ' ')){ return 1; } return 0; } -int backtracking(char* maze, int x, int y, int size){ -if(x == size - 1 && y == size - 1 && maze[x * size + y] == ' '){ +int backtracking(char* maze, int x, int y, int size){ //https://www.geeksforgeeks.org/rat-in-a-maze-backtracking-2/ +if(x == size - 1 && y == size - 1 && maze[x * size + y] == ' '){ //kontrola ci sa nachadzam na konci maze[x * size + y] = '*'; return 1; } - if(issafe(maze, x, y, size) == 1) { + if(issafe(maze, x, y, size) == 1) { // znazornenie stien maze[x * size + y] = '*'; if (backtracking(maze, x, y + 1, size) == 1) { diff --git a/sk2a/compressor.c b/sk2a/compressor.c index c45b0cb..e7ee5c4 100644 --- a/sk2a/compressor.c +++ b/sk2a/compressor.c @@ -24,7 +24,7 @@ void delete(struct dict* tree){ for (int i = 0 ;i < SIZE; i++){ delete(tree-> characters[i]); } - free(tree); + } void get_words (struct dict* tree,char* words[]){ @@ -102,7 +102,7 @@ int mylz78compress(char* buff,int size,char** outbuf){ } delete(root); - free(words); + *outbuf = temp; return strlen(temp); @@ -183,9 +183,7 @@ void compress(FILE* infile,FILE* outfile){ fwrite(outbuf,sizeof(char),outsize,outfile); } - free(buffer); - free(tempbuf); - free(outbuf); + } @@ -204,7 +202,6 @@ int myrldecompress(char* buff,int size,char** outbuf){ char *tempbuf = calloc(size,sizeof(char)); memset(tempbuf,'\0',size); strcpy(tempbuf,*outbuf); - free(*outbuf); *outbuf = tempbuf; } @@ -242,7 +239,6 @@ int mylz78decompress(char* buff,int size,char** outbuf){ char *tempbuf = calloc(size,sizeof(char)); memset(tempbuf,'\0',size); strcpy(tempbuf,*outbuf); - free(*outbuf); *outbuf = tempbuf; } @@ -278,8 +274,5 @@ void decompress(FILE* infile,FILE* outfile){ fwrite(outbuf,sizeof(char),outsize,outfile); } - free(buffer); - free(tempbuf); - free(outbuf); } diff --git a/sk2a/program b/sk2a/program index c6f2609..e57f5bd 100644 Binary files a/sk2a/program and b/sk2a/program differ diff --git a/sk2a/readme.md b/sk2a/readme.md index 37b1c38..2316976 100644 --- a/sk2a/readme.md +++ b/sk2a/readme.md @@ -24,7 +24,6 @@ return; for (int i = 0 ;i < SIZE; i++){ delete(tree-> characters[i]); } -free(tree); } void get_words (struct dict* tree,char* words[]){ //posielam cely strom a smernik na dvojrozmerne pole @@ -102,7 +101,7 @@ sprintf(last,"-%d-%c\n",current->index,c); // } delete(root); //nepotrebujeme strom, uvolnime pamat - free(words); + *outbuf = temp; //adresa sa zapise do outbuffer return strlen(temp); @@ -183,9 +182,7 @@ char *buffer = calloc(insize,sizeof(char)); //alokuje pamat fwrite(outbuf,sizeof(char),outsize,outfile); //napise sa do suboru, z akeho buffera do akeho suboru } - free(buffer); - free(tempbuf); - free(outbuf); + } @@ -204,7 +201,6 @@ memset(*outbuf,0,size + 1); char *tempbuf = calloc(size,sizeof(char)); memset(tempbuf,'\0',size); strcpy(tempbuf,*outbuf); - free(*outbuf); *outbuf = tempbuf; } @@ -242,7 +238,6 @@ int bytes_read, bytes_read_all = 0; //citame vstupny buffer, necitame p char *tempbuf = calloc(size,sizeof(char)); memset(tempbuf,'\0',size); strcpy(tempbuf,*outbuf); - free(*outbuf); *outbuf = tempbuf; } @@ -278,7 +273,4 @@ char *buffer = calloc(insize,sizeof(char)); fwrite(outbuf,sizeof(char),outsize,outfile); } - free(buffer); - free(tempbuf); - free(outbuf); } \ No newline at end of file