Browse Source

Fix some memory leaks

Signed-off-by: wmb <wmb@teknik.io>
master
wmb 1 year ago
parent
commit
0de435b2cf
  1. 15
      main.c

15
main.c

@ -89,12 +89,9 @@ int main(int argc, char *argv[]) @@ -89,12 +89,9 @@ int main(int argc, char *argv[])
while (!solution_voisine(&new_solution, solution_opt))
continue; /* do it again */
/* TODO: Calculer les centres de gravités, les distances moyennes inter-/intra-cluster,
* et faire le reste de l'algorithme */
if ((f1 = fonction_objective(new_solution)) > f0) {
print_solution(new_solution, "optimale trouvée");
printf("F(solution) = %f\n", f1);
printf("F(solution) = %f (%f%% improvement)\n", f1, fabs((f1 - f0) / f0 * 100.0));
free(solution_opt);
solution_opt = new_solution;
new_solution = NULL;
@ -102,6 +99,16 @@ int main(int argc, char *argv[]) @@ -102,6 +99,16 @@ int main(int argc, char *argv[])
}
}
/* Free solution data */
free(solution_opt);
free(new_solution);
/* Free benchmark data */
for (i = 0; i < (int) N_VECTORS; i++)
free(benchmark_data[i]);
free(benchmark_data);
exit(EXIT_SUCCESS);
}

Loading…
Cancel
Save