Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use simgrid::xbt::Path instead of xbt_{base,dir}name in C++ files.
[simgrid.git] / src / mc / remote / RemoteClient.cpp
index 37abc50..297c545 100644 (file)
@@ -28,6 +28,7 @@
 #include <libunwind.h>
 
 #include "xbt/base.h"
+#include "xbt/file.hpp"
 #include "xbt/log.h"
 #include <xbt/mmalloc.h>
 
@@ -46,12 +47,12 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_process, mc, "MC process information");
 
 // ***** Helper stuff
 
-namespace simgrid {
-namespace mc {
-
 #define SO_RE "\\.so[\\.0-9]*$"
 #define VERSION_RE "-[\\.0-9-]*$"
 
+namespace simgrid {
+namespace mc {
+
 // List of library which memory segments are not considered:
 static const char* const filtered_libraries[] = {
 #ifdef __linux__
@@ -118,17 +119,13 @@ struct s_mc_memory_map_re {
 
 static char* get_lib_name(const char* pathname, s_mc_memory_map_re* res)
 {
-  char* map_basename = xbt_basename(pathname);
+  std::string map_basename = simgrid::xbt::Path(pathname).getBasename();
 
   regmatch_t match;
-  if (regexec(&res->so_re, map_basename, 1, &match, 0)) {
-    free(map_basename);
+  if (regexec(&res->so_re, map_basename.c_str(), 1, &match, 0))
     return nullptr;
-  }
 
-  char* libname = strndup(map_basename, match.rm_so);
-  free(map_basename);
-  map_basename = nullptr;
+  char* libname = strndup(map_basename.c_str(), match.rm_so);
 
   // Strip the version suffix:
   if (libname && not regexec(&res->version_re, libname, 1, &match, 0)) {