Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix bug in keyval delete
authorAugustin Degomme <augustin.degomme@imag.fr>
Mon, 6 Oct 2014 12:41:37 +0000 (14:41 +0200)
committerAugustin Degomme <augustin.degomme@imag.fr>
Mon, 6 Oct 2014 12:41:37 +0000 (14:41 +0200)
src/smpi/smpi_comm.c
src/smpi/smpi_mpi_dt.c

index 2e3bf4f..4c02837 100644 (file)
@@ -623,11 +623,13 @@ int smpi_comm_keyval_create(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delet
 }
 
 int smpi_comm_keyval_free(int* keyval){
-  smpi_comm_key_elem elem = xbt_dict_get_or_null(smpi_comm_keyvals, (const char*)keyval);
-  if(!elem)
-    return MPI_ERR_ARG;
   char* tmpkey=xbt_malloc(INTSIZEDCHAR);
   sprintf(tmpkey, "%d", *keyval);
+  smpi_comm_key_elem elem = xbt_dict_get_or_null(smpi_comm_keyvals, (const char*)tmpkey);
+  if(!elem){
+    xbt_free(tmpkey);
+    return MPI_ERR_ARG;
+  }
   xbt_dict_remove(smpi_comm_keyvals, (const char*)tmpkey);
   xbt_free(elem);
   xbt_free(tmpkey);
index c5e93f3..047cf91 100644 (file)
@@ -1757,11 +1757,13 @@ int smpi_type_keyval_create(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delet
 }
 
 int smpi_type_keyval_free(int* keyval){
-  smpi_type_key_elem elem = xbt_dict_get_or_null(smpi_type_keyvals, (const char*)keyval);
-  if(!elem)
-    return MPI_ERR_ARG;
   char* tmpkey=xbt_malloc(INTSIZEDCHAR);
   sprintf(tmpkey, "%d", *keyval);
+  smpi_type_key_elem elem = xbt_dict_get_or_null(smpi_type_keyvals, (const char*)tmpkey);
+  if(!elem){
+    xbt_free(tmpkey);
+    return MPI_ERR_ARG;
+  }
   xbt_dict_remove(smpi_type_keyvals, (const char*)tmpkey);
   xbt_free(elem);
   xbt_free(tmpkey);