From 36c68a000e3b0156ac5c92ac479bd3b82f76bfde Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 15 Aug 2016 13:45:50 +0200 Subject: [PATCH] plug two memleak in smpi, and cosmetics --- src/smpi/smpi_comm.cpp | 1 + src/smpi/smpi_f77.cpp | 8 +++++++- src/smpi/smpi_mpi_dt.cpp | 15 +++++++-------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/smpi/smpi_comm.cpp b/src/smpi/smpi_comm.cpp index 22aab8e289..99625ce3f0 100644 --- a/src/smpi/smpi_comm.cpp +++ b/src/smpi/smpi_comm.cpp @@ -111,6 +111,7 @@ int smpi_comm_dup(MPI_Comm comm, MPI_Comm* newcomm){ if(ret!=MPI_SUCCESS){ smpi_comm_destroy(*newcomm); *newcomm=MPI_COMM_NULL; + xbt_dict_cursor_free(&cursor); return ret; } if(flag) diff --git a/src/smpi/smpi_f77.cpp b/src/smpi/smpi_f77.cpp index 76683814c6..0ab3b36d02 100644 --- a/src/smpi/smpi_f77.cpp +++ b/src/smpi/smpi_f77.cpp @@ -778,8 +778,8 @@ void mpi_info_set_( int *info, char *key, char *value, int* ierr, unsigned int k } char* tvalue = xbt_new(char,valuelen+1); strncpy(tvalue, value, valuelen); - tvalue[valuelen]='\0'; + *ierr = MPI_Info_set( smpi_info_f2c(*info), tkey, tvalue); xbt_free(tkey); } @@ -810,6 +810,12 @@ void mpi_info_get_ (int* info,char *key,int* valuelen, char *value, int *flag, i void mpi_info_free_(int* info, int* ierr){ MPI_Info tmp = smpi_info_f2c(*info); + const char* key; + char* val; + xbt_dict_cursor_t cursor; + xbt_dict_foreach(tmp->info_dict,cursor,key,val) { + xbt_free(val); + } *ierr = MPI_Info_free(&tmp); if(*ierr == MPI_SUCCESS) { free_info(*info); diff --git a/src/smpi/smpi_mpi_dt.cpp b/src/smpi/smpi_mpi_dt.cpp index 43af712336..5f66b310be 100644 --- a/src/smpi/smpi_mpi_dt.cpp +++ b/src/smpi/smpi_mpi_dt.cpp @@ -25,12 +25,12 @@ int type_keyval_id=0;//avoid collisions static s_smpi_mpi_datatype_t mpi_##name = { \ (char*) # name, \ sizeof(type), /* size */ \ - 0, /*was 1 sizeof_substruct*/ \ + 0, /*was 1 sizeof_substruct*/ \ 0, /* lb */ \ sizeof(type), /* ub = lb + size */ \ DT_FLAG_BASIC, /* flags */ \ - nullptr, /* attributes */ \ - nullptr, /* pointer on extended struct*/ \ + nullptr, /* attributes */ \ + nullptr, /* pointer on extended struct*/ \ 0 /* in_use counter */ \ }; \ const MPI_Datatype name = &mpi_##name; @@ -39,12 +39,12 @@ const MPI_Datatype name = &mpi_##name; static s_smpi_mpi_datatype_t mpi_##name = { \ (char*) # name, \ 0, /* size */ \ - 0, /* was 1 sizeof_substruct*/ \ + 0, /* was 1 sizeof_substruct*/ \ 0, /* lb */ \ 0, /* ub = lb + size */ \ DT_FLAG_BASIC, /* flags */ \ - nullptr, /* attributes */ \ - nullptr, /* pointer on extended struct*/ \ + nullptr, /* attributes */ \ + nullptr, /* pointer on extended struct*/ \ 0 /* in_use counter */ \ }; \ const MPI_Datatype name = &mpi_##name; @@ -930,8 +930,7 @@ s_smpi_mpi_hindexed_t* smpi_datatype_hindexed_create( int* block_lengths, MPI_Ai new_t->base.subtype_use = &use_hindexed; new_t->block_lengths= xbt_new(int, block_count); new_t->block_indices= xbt_new(MPI_Aint, block_count); - int i; - for(i=0;iblock_lengths[i]=block_lengths[i]; new_t->block_indices[i]=block_indices[i]; } -- 2.20.1