#include "src/internal_config.h"
#include "src/mc/mc_private.hpp"
#include "src/smpi/include/private.hpp"
+#include "xbt/file.hpp"
#include "xbt/mmalloc.h"
#include "xbt/module.h"
std::vector<simgrid::xbt::VmMap> const& maps,
simgrid::mc::ObjectInformation* result)
{
- char* name = xbt_basename(result->file_name.c_str());
+ std::string name = simgrid::xbt::Path(result->file_name).getBasename();
for (size_t i = 0; i < maps.size(); ++i) {
simgrid::xbt::VmMap const& reg = maps[i];
if (maps[i].pathname.empty())
continue;
- char* map_basename = xbt_basename(maps[i].pathname.c_str());
- if (strcmp(name, map_basename) != 0) {
- free(map_basename);
+ std::string map_basename = simgrid::xbt::Path(maps[i].pathname).getBasename();
+ if (map_basename != name)
continue;
- }
- free(map_basename);
// This is the non-GNU_RELRO-part of the data segment:
if (reg.prot == PROT_RW) {
result->end = result->end_exec;
xbt_assert(result->start_exec || result->start_rw || result->start_ro);
-
- free(name);
}
/************************************* Take Snapshot ************************************/
// If dot_output enabled, do not handle the corresponding file
if (dot_output != nullptr) {
- char* link_basename = xbt_basename(link);
- if (strcmp(link_basename, _sg_mc_dot_output_file) == 0) {
- free(link_basename);
+ std::string link_basename = simgrid::xbt::Path(link).getBasename();
+ if (link_basename == _sg_mc_dot_output_file)
continue;
- }
- free(link_basename);
}
// This is probably a shared memory used by lttng-ust:
#include <libunwind.h>
#include "xbt/base.h"
+#include "xbt/file.hpp"
#include "xbt/log.h"
#include <xbt/mmalloc.h>
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)) {
#include "simdag_private.hpp"
#include "simgrid/simdag.h"
-#include "xbt/file.h" /* xbt_basename() */
+#include "xbt/file.hpp"
#include "xbt/log.h"
#include "xbt/misc.h"
#include <map>
}
if (not acyclic_graph_detail(result)) {
- char* base = xbt_basename(filename);
- XBT_ERROR("The DAX described in %s is not a DAG. It contains a cycle.", base);
- free(base);
+ std::string base = simgrid::xbt::Path(filename).getBasename();
+ XBT_ERROR("The DAX described in %s is not a DAG. It contains a cycle.", base.c_str());
xbt_dynar_foreach(result, cpt, file)
SD_task_destroy(file);
xbt_dynar_free_container(&result);
#include "simdag_private.hpp"
#include "simgrid/simdag.h"
#include "src/internal_config.h"
-#include "xbt/file.h"
+#include "xbt/file.hpp"
#include <cstring>
#include <unordered_map>
}
if (result && not acyclic_graph_detail(result)) {
- char* base = xbt_basename(filename);
- XBT_ERROR("The DOT described in %s is not a DAG. It contains a cycle.", base);
- free(base);
+ std::string base = simgrid::xbt::Path(filename).getBasename();
+ XBT_ERROR("The DOT described in %s is not a DAG. It contains a cycle.", base.c_str());
xbt_dynar_free(&result);
result = nullptr;
}
#include "simgrid/sg_config.h"
#include "src/kernel/routing/NetPoint.hpp"
#include "src/surf/network_interface.hpp"
-#include "xbt/file.h"
+#include "xbt/file.hpp"
#include "src/surf/xml/platf_private.hpp"
#include <boost/algorithm/string.hpp>
xbt_assert(file, "Cannot parse the nullptr file. Bypassing the parser is strongly deprecated nowadays.");
surf_parsed_filename = xbt_strdup(file);
- char* dir = xbt_dirname(file);
- surf_path.push_back(std::string(dir));
- xbt_free(dir);
+ std::string dir = simgrid::xbt::Path(file).getDirname();
+ surf_path.push_back(dir);
surf_file_to_parse = surf_fopen(file, "r");
if (surf_file_to_parse == nullptr)