Commit d0c9fe98 authored by iker_martin's avatar iker_martin
Browse files

Fixed two minor memory leaks/issues detected by Valgrind

parent ffab3976
...@@ -135,18 +135,14 @@ void free_config(configuration *user_config) { ...@@ -135,18 +135,14 @@ void free_config(configuration *user_config) {
} }
} }
//Liberar tipos derivados //Liberar tipos derivados
if(user_config->config_type != MPI_DATATYPE_NULL) { //FIXME No se libera MPI_Type_free(&(user_config->config_type));
MPI_Type_free(&(user_config->config_type)); user_config->config_type = MPI_DATATYPE_NULL;
user_config->config_type = MPI_DATATYPE_NULL;
} MPI_Type_free(&(user_config->group_type));
if(user_config->group_type != MPI_DATATYPE_NULL) { user_config->group_type = MPI_DATATYPE_NULL;
MPI_Type_free(&(user_config->group_type));
user_config->group_type = MPI_DATATYPE_NULL; MPI_Type_free(&(user_config->iter_stage_type));
} user_config->iter_stage_type = MPI_DATATYPE_NULL;
if(user_config->iter_stage_type != MPI_DATATYPE_NULL) {
MPI_Type_free(&(user_config->iter_stage_type));
user_config->iter_stage_type = MPI_DATATYPE_NULL;
}
free(user_config->groups); free(user_config->groups);
free(user_config->stages); free(user_config->stages);
...@@ -326,7 +322,7 @@ void def_struct_groups(configuration *config_file) { ...@@ -326,7 +322,7 @@ void def_struct_groups(configuration *config_file) {
// Tipo derivado para enviar N elementos de la estructura // Tipo derivado para enviar N elementos de la estructura
MPI_Type_create_resized(aux, 0, sizeof(group_config_t), &(config_file->group_type)); MPI_Type_create_resized(aux, 0, sizeof(group_config_t), &(config_file->group_type));
MPI_Type_commit(&(config_file->group_type)); MPI_Type_commit(&(config_file->group_type));
// MPI_Type_free(&aux); //FIXME It should be freed MPI_Type_free(&aux);
} }
} }
...@@ -364,6 +360,6 @@ void def_struct_iter_stage(configuration *config_file) { ...@@ -364,6 +360,6 @@ void def_struct_iter_stage(configuration *config_file) {
// Tipo derivado para enviar N elementos de la estructura // Tipo derivado para enviar N elementos de la estructura
MPI_Type_create_resized(aux, 0, sizeof(iter_stage_t), &(config_file->iter_stage_type)); MPI_Type_create_resized(aux, 0, sizeof(iter_stage_t), &(config_file->iter_stage_type));
MPI_Type_commit(&(config_file->iter_stage_type)); MPI_Type_commit(&(config_file->iter_stage_type));
// MPI_Type_free(&aux); //FIXME It should be freed MPI_Type_free(&aux);
} }
} }
...@@ -21,7 +21,7 @@ void malloc_comm_array(char **array, int qty, int myId, int numP) { ...@@ -21,7 +21,7 @@ void malloc_comm_array(char **array, int qty, int myId, int numP) {
struct Dist_data dist_data; struct Dist_data dist_data;
get_block_dist(qty, myId, numP, &dist_data); get_block_dist(qty, myId, numP, &dist_data);
if( (*array = malloc(dist_data.tamBl * sizeof(char))) == NULL) { if( (*array = calloc(dist_data.tamBl, sizeof(char))) == NULL) {
printf("Memory Error (Malloc Arrays(%d))\n", dist_data.tamBl); printf("Memory Error (Malloc Arrays(%d))\n", dist_data.tamBl);
exit(1); exit(1);
} }
...@@ -72,8 +72,8 @@ int sync_communication(char *send, char **recv, int qty, int myId, int numP, int ...@@ -72,8 +72,8 @@ int sync_communication(char *send, char **recv, int qty, int myId, int numP, int
// Obtener distribución para este hijo // Obtener distribución para este hijo
get_block_dist(qty, myId, numP, &dist_data); get_block_dist(qty, myId, numP, &dist_data);
*recv = malloc(dist_data.tamBl * sizeof(char)); *recv = malloc(dist_data.tamBl * sizeof(char));
get_block_dist(qty, myId, numP, &dist_data); //get_block_dist(qty, myId, numP, &dist_data);
print_counts(dist_data, r_counts.counts, r_counts.displs, numO, 1, "Children C"); //print_counts(dist_data, r_counts.counts, r_counts.displs, numO, 1, "Children C");
} else { } else {
prepare_comm_alltoall(myId, numP, numO, qty, &s_counts); prepare_comm_alltoall(myId, numP, numO, qty, &s_counts);
...@@ -89,9 +89,9 @@ int sync_communication(char *send, char **recv, int qty, int myId, int numP, int ...@@ -89,9 +89,9 @@ int sync_communication(char *send, char **recv, int qty, int myId, int numP, int
} else { } else {
mallocCounts(&r_counts, numP); mallocCounts(&r_counts, numP);
} }
get_block_dist(qty, myId, numP, &dist_data); //get_block_dist(qty, myId, numP, &dist_data);
print_counts(dist_data, r_counts.counts, r_counts.displs, numP, 1, "Children P "); //print_counts(dist_data, r_counts.counts, r_counts.displs, numP, 1, "Children P ");
print_counts(dist_data, s_counts.counts, s_counts.displs, numO, 1, "Parents "); //print_counts(dist_data, s_counts.counts, s_counts.displs, numO, 1, "Parents ");
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment