fix(01): Fix memory leaks

This commit is contained in:
Jiří Štefka 2024-12-03 14:20:43 +01:00
parent ab4e7a7edb
commit fddf7ab780
Signed by: jiriks74
GPG Key ID: 1D5E30D3DB2264DE

@ -72,14 +72,14 @@ int main(int argc, char *argv[])
rewind(file); rewind(file);
for (uint i = 0; i < lines; i++) { for (uint i = 0; i < lines; i++) {
char *buffer = NULL;
size_t bufferSize = 0;
if (getline(&buffer, &bufferSize, file) == -1) if (getline(&buffer, &bufferSize, file) == -1)
break; break;
sscanf(buffer, "%d %d", &array1[i], &array2[i]); sscanf(buffer, "%d %d", &array1[i], &array2[i]);
} }
free(buffer);
bufferSize = 0;
fclose(file); fclose(file);
qsort(array1, lines, sizeof(int), compareInt); qsort(array1, lines, sizeof(int), compareInt);