From cf90e56150ac95ab17f0c421f973597f7c55c054 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 3 Apr 2014 11:46:56 +0200 Subject: [PATCH] Fix memory leak on file_unlink. --- src/simix/smx_io.c | 8 +++----- src/surf/workstation_interface.cpp | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/simix/smx_io.c b/src/simix/smx_io.c index 10b39e9207..969991b74e 100644 --- a/src/simix/smx_io.c +++ b/src/simix/smx_io.c @@ -201,11 +201,9 @@ int SIMIX_file_unlink(smx_process_t process, smx_file_t fd) 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) diff --git a/src/surf/workstation_interface.cpp b/src/surf/workstation_interface.cpp index ba19f668d3..f37bff3ae6 100644 --- a/src/surf/workstation_interface.cpp +++ b/src/surf/workstation_interface.cpp @@ -284,8 +284,8 @@ int Workstation::unlink(surf_file_t fd) { // 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; } -- 2.20.1