From: Pierre Veyre Date: Fri, 21 Mar 2014 08:43:29 +0000 (+0100) Subject: Leak -- X-Git-Tag: v3_11~204 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/172fee8426c6ef02fe4e2603312e12e6f709c0fe Leak -- --- diff --git a/src/surf/storage_interface.hpp b/src/surf/storage_interface.hpp index 5b89f8d638..7e17d8e183 100644 --- a/src/surf/storage_interface.hpp +++ b/src/surf/storage_interface.hpp @@ -182,7 +182,7 @@ public: * * @return The StorageAction corresponding to the opening */ - virtual StorageActionPtr open(const char* mount, char* path)=0; + virtual StorageActionPtr open(char* mount, char* path)=0; /** * @brief Close a file diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 2856220bf1..289e657470 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -406,7 +406,7 @@ StorageActionPtr StorageN11::ls(const char* path) return action; } -StorageActionPtr StorageN11::open(const char* mount, char* path) +StorageActionPtr StorageN11::open(char* mount, char* path) { XBT_DEBUG("\tOpen file '%s'",path); @@ -431,6 +431,8 @@ StorageActionPtr StorageN11::open(const char* mount, char* path) StorageActionPtr action = new StorageN11Action(getModel(), 0, getState() != SURF_RESOURCE_ON, this, OPEN); action->p_file = file; free(path); + free(mount); + return action; } diff --git a/src/surf/storage_n11.hpp b/src/surf/storage_n11.hpp index f682ea558f..86139ccc92 100644 --- a/src/surf/storage_n11.hpp +++ b/src/surf/storage_n11.hpp @@ -53,7 +53,7 @@ public: lmm_system_t maxminSystem, double bread, double bwrite, double bconnection, const char* type_id, char *content_name, char *content_type, sg_size_t size, char *attach); - StorageActionPtr open(const char* mount, char* path); + StorageActionPtr open(char* mount, char* path); StorageActionPtr close(surf_file_t fd); StorageActionPtr ls(const char *path); StorageActionPtr read(surf_file_t fd, sg_size_t size);//FIXME:why we have a useless param ptr ?? diff --git a/src/surf/workstation_interface.cpp b/src/surf/workstation_interface.cpp index 8ff047a8d5..c7798bd04c 100644 --- a/src/surf/workstation_interface.cpp +++ b/src/surf/workstation_interface.cpp @@ -222,9 +222,10 @@ ActionPtr Workstation::open(const char* fullpath) { if(!strcmp(file_mount_name,mnt.name) && strlen(mnt.name)>pos) {/* The current mount name is found in the full path and is bigger than the previous*/ pos = strlen(mnt.name); - mount_name = mnt.name; + mount_name = strdup(mnt.name); st = static_cast(mnt.storage); } + free(file_mount_name); } if(pos>0) { /* Mount point found, deduce path + file name from full path (full path = mount name + path + file name)*/ @@ -235,7 +236,6 @@ ActionPtr Workstation::open(const char* fullpath) { else xbt_die("Can't find mount point for '%s' on '%s'", fullpath, getName()); - free(file_mount_name); return st->open(mount_name, path); }