@@ -366,24 +366,20 @@ mca_fcoll_dynamic_file_write_all (mca_io_ompio_file_t *fh,
366366 goto exit ;
367367 }
368368
369- blocklen_per_process = (int * * )malloc (fh -> f_procs_per_group * sizeof (int * ));
369+ blocklen_per_process = (int * * )calloc (fh -> f_procs_per_group , sizeof (int * ));
370370 if (NULL == blocklen_per_process ) {
371371 opal_output (1 , "OUT OF MEMORY\n" );
372372 ret = OMPI_ERR_OUT_OF_RESOURCE ;
373373 goto exit ;
374374 }
375375
376- displs_per_process = (MPI_Aint * * )malloc (fh -> f_procs_per_group * sizeof (MPI_Aint * ));
376+ displs_per_process = (MPI_Aint * * )calloc (fh -> f_procs_per_group , sizeof (MPI_Aint * ));
377377 if (NULL == displs_per_process ) {
378378 opal_output (1 , "OUT OF MEMORY\n" );
379379 ret = OMPI_ERR_OUT_OF_RESOURCE ;
380380 goto exit ;
381381 }
382382
383- for (i = 0 ;i < fh -> f_procs_per_group ;i ++ ){
384- blocklen_per_process [i ] = NULL ;
385- displs_per_process [i ] = NULL ;
386- }
387383 recv_req = (MPI_Request * )malloc ((fh -> f_procs_per_group )* sizeof (MPI_Request ));
388384 if ( NULL == recv_req ) {
389385 opal_output (1 , "OUT OF MEMORY\n" );
@@ -439,22 +435,12 @@ mca_fcoll_dynamic_file_write_all (mca_io_ompio_file_t *fh,
439435 for (l = 0 ;l < fh -> f_procs_per_group ;l ++ ){
440436 disp_index [l ] = 1 ;
441437
442- if (NULL != blocklen_per_process [l ]){
443- free (blocklen_per_process [l ]);
444- blocklen_per_process [l ] = NULL ;
445- }
446- if (NULL != displs_per_process [l ]){
447- free (displs_per_process [l ]);
448- displs_per_process [l ] = NULL ;
449- }
438+ free (blocklen_per_process [l ]);
439+ free (displs_per_process [l ]);
440+
450441 blocklen_per_process [l ] = (int * ) calloc (1 , sizeof (int ));
451- if (NULL == blocklen_per_process [l ]) {
452- opal_output (1 , "OUT OF MEMORY for blocklen\n" );
453- ret = OMPI_ERR_OUT_OF_RESOURCE ;
454- goto exit ;
455- }
456442 displs_per_process [l ] = (MPI_Aint * ) calloc (1 , sizeof (MPI_Aint ));
457- if (NULL == displs_per_process [l ]){
443+ if (NULL == displs_per_process [l ] || NULL == blocklen_per_process [ l ] ){
458444 opal_output (1 , "OUT OF MEMORY for displs\n" );
459445 ret = OMPI_ERR_OUT_OF_RESOURCE ;
460446 goto exit ;
@@ -1044,24 +1030,16 @@ exit :
10441030 global_buf = NULL ;
10451031 }
10461032 for (l = 0 ;l < fh -> f_procs_per_group ;l ++ ){
1047- if (NULL != blocklen_per_process [ l ] ){
1033+ if (NULL != blocklen_per_process ){
10481034 free (blocklen_per_process [l ]);
1049- blocklen_per_process [l ] = NULL ;
10501035 }
1051- if (NULL != displs_per_process [ l ] ){
1036+ if (NULL != displs_per_process ){
10521037 free (displs_per_process [l ]);
1053- displs_per_process [l ] = NULL ;
10541038 }
10551039 }
1056- if (NULL != blocklen_per_process ){
1057- free (blocklen_per_process );
1058- blocklen_per_process = NULL ;
1059- }
1060- if (NULL != displs_per_process ){
1061- free (displs_per_process );
1062- displs_per_process = NULL ;
1063- }
10641040
1041+ free (blocklen_per_process );
1042+ free (displs_per_process );
10651043 }
10661044
10671045 if (NULL != displs ){
0 commit comments