Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Iker Martín Álvarez
Proteo
Commits
d0c9fe98
Commit
d0c9fe98
authored
Feb 14, 2023
by
iker_martin
Browse files
Fixed two minor memory leaks/issues detected by Valgrind
parent
ffab3976
Changes
2
Show whitespace changes
Inline
Side-by-side
Codes/Main/configuration.c
View file @
d0c9fe98
...
...
@@ -135,18 +135,14 @@ void free_config(configuration *user_config) {
}
}
//Liberar tipos derivados
if
(
user_config
->
config_type
!=
MPI_DATATYPE_NULL
)
{
//FIXME No se libera
MPI_Type_free
(
&
(
user_config
->
config_type
));
user_config
->
config_type
=
MPI_DATATYPE_NULL
;
}
if
(
user_config
->
group_type
!=
MPI_DATATYPE_NULL
)
{
MPI_Type_free
(
&
(
user_config
->
group_type
));
user_config
->
group_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
->
stages
);
...
...
@@ -326,7 +322,7 @@ void def_struct_groups(configuration *config_file) {
// 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_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) {
// 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_commit
(
&
(
config_file
->
iter_stage_type
));
//
MPI_Type_free(&aux);
//FIXME It should be freed
MPI_Type_free
(
&
aux
);
}
}
Codes/malleability/CommDist.c
View file @
d0c9fe98
...
...
@@ -21,7 +21,7 @@ void malloc_comm_array(char **array, int qty, int myId, int numP) {
struct
Dist_data
dist_data
;
get_block_dist
(
qty
,
myId
,
numP
,
&
dist_data
);
if
(
(
*
array
=
m
alloc
(
dist_data
.
tamBl
*
sizeof
(
char
)))
==
NULL
)
{
if
(
(
*
array
=
c
alloc
(
dist_data
.
tamBl
,
sizeof
(
char
)))
==
NULL
)
{
printf
(
"Memory Error (Malloc Arrays(%d))
\n
"
,
dist_data
.
tamBl
);
exit
(
1
);
}
...
...
@@ -72,8 +72,8 @@ int sync_communication(char *send, char **recv, int qty, int myId, int numP, int
// Obtener distribución para este hijo
get_block_dist
(
qty
,
myId
,
numP
,
&
dist_data
);
*
recv
=
malloc
(
dist_data
.
tamBl
*
sizeof
(
char
));
get_block_dist
(
qty
,
myId
,
numP
,
&
dist_data
);
print_counts
(
dist_data
,
r_counts
.
counts
,
r_counts
.
displs
,
numO
,
1
,
"Children C"
);
//
get_block_dist(qty, myId, numP, &dist_data);
//
print_counts(dist_data, r_counts.counts, r_counts.displs, numO, 1, "Children C");
}
else
{
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
}
else
{
mallocCounts
(
&
r_counts
,
numP
);
}
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
,
s_counts
.
counts
,
s_counts
.
displs
,
numO
,
1
,
"Parents "
);
//
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, s_counts.counts, s_counts.displs, numO, 1, "Parents ");
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment