Skip to content

Commit 582511f

Browse files
committed
Documented and refactored tst_array_compress()
1 parent 62b0cee commit 582511f

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

mpi_test_suite.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,25 @@ int tst_hash_value (const struct tst_env * env)
8787
env->test) % tst_tag_ub;
8888
}
8989

90-
static int tst_array_compress (int * list, const int list_max, int * list_num)
91-
{
90+
/** \brief Compress array, by removing all -1 entries
91+
*
92+
* \param[in,out] list array list to be compressed
93+
* \param[in] list_max number of elements in list
94+
* \param[out] list_num number of elements in list after compression
95+
*
96+
* \return number of elements after compression
97+
*/
98+
static int tst_array_compress(int *list, const int list_max, int *list_num) {
9299
int i;
93-
int current_pos;
94-
/*
95-
* Compress array, by removing all -1 entries.
96-
*/
97-
for (current_pos = i = 0; i < list_max; i++)
98-
{
100+
int current_pos = 0;
101+
for (i = 0; i < list_max; i++) {
102+
if (list[i] != -1) {
99103
list[current_pos] = list[i];
100-
tst_output_printf (DEBUG_LOG, TST_REPORT_FULL, "(Rank:%d) tst_array_compress list[%d]=list[%d]:%d\n",
101-
tst_global_rank, current_pos, i, list[current_pos]);
102-
if (list[i] != -1)
103-
current_pos++;
104+
current_pos++;
104105
}
106+
}
105107
(*list_num) = current_pos;
106-
return 0;
108+
return current_pos;
107109
}
108110

109111

0 commit comments

Comments
 (0)