Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix memory leak on file_unlink.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 3 Apr 2014 09:46:56 +0000 (11:46 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Fri, 4 Apr 2014 08:27:10 +0000 (10:27 +0200)
src/simix/smx_io.c
src/surf/workstation_interface.cpp

index 10b39e9..969991b 100644 (file)
@@ -201,11 +201,9 @@ int SIMIX_file_unlink(smx_process_t process, smx_file_t fd)
            sg_host_name(host));
   }
 
            sg_host_name(host));
   }
 
-  if (surf_workstation_unlink(host, fd->surf_file)){
-    xbt_free(fd);
-    return 1;
-  } else
-    return 0;
+  int res = surf_workstation_unlink(host, fd->surf_file);
+  xbt_free(fd);
+  return !!res;
 }
 
 sg_size_t SIMIX_pre_file_get_size(smx_simcall_t simcall, smx_file_t fd)
 }
 
 sg_size_t SIMIX_pre_file_get_size(smx_simcall_t simcall, smx_file_t fd)
index ba19f66..f37bff3 100644 (file)
@@ -284,8 +284,8 @@ int Workstation::unlink(surf_file_t fd) {
       // Remove the file from storage
       xbt_dict_remove(st->p_content, fd->name);
 
       // Remove the file from storage
       xbt_dict_remove(st->p_content, fd->name);
 
-      free(fd->name);
-      free(fd->mount);
+      xbt_free(fd->name);
+      xbt_free(fd->mount);
       xbt_free(fd);
       return MSG_OK;
     }
       xbt_free(fd);
       return MSG_OK;
     }