extern XBT_PRIVATE double sg_bandwidth_factor;
extern XBT_PRIVATE double sg_weight_S_parameter;
extern XBT_PRIVATE int sg_network_crosstraffic;
-extern XBT_PRIVATE xbt_dynar_t surf_path;
#ifdef __cplusplus
#include "mc/mc.h"
#include "simgrid/instr.h"
#include "src/mc/mc_replay.h"
+#include "src/surf/surf_interface.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_config, surf, "About the configuration of SimGrid");
"",
[](std::string const& path) {
if (path[0] != '\0') {
- char* copy = xbt_strdup(path.c_str());
- xbt_dynar_push(surf_path, ©);
+ surf_path.push_back(path);
}
});
"Whether to cleanup SimGrid at exit. Disable it if your code segfaults after its end.");
xbt_cfg_register_alias("clean-atexit","clean_atexit");
- if (!surf_path) {
+ if (surf_path.empty()) {
/* retrieves the current directory of the current process */
const char *initial_path = __surf_get_initial_path();
xbt_assert((initial_path), "__surf_get_initial_path() failed! Can't resolve current Windows directory");
- surf_path = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
xbt_cfg_setdefault_string("path", initial_path);
}
#include "storage_interface.hpp"
#include "surf_private.h"
#include "xbt/file.h" /* xbt_getline */
+#include <boost/algorithm/string/join.hpp>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf, "Logging specific to the SURF storage module");
xbt_dict_t parse_content = xbt_dict_new_homogeneous(xbt_free_f);
FILE *file = surf_fopen(filename, "r");
- xbt_assert(file, "Cannot open file '%s' (path=%s)", filename, xbt_str_join(surf_path, ":"));
+ xbt_assert(file, "Cannot open file '%s' (path=%s)", filename, (boost::join(surf_path, ":")).c_str());
char *line = nullptr;
size_t len = 0;
std::vector<surf_model_t> * all_existing_models = nullptr; /* to destroy models correctly */
simgrid::trace_mgr::future_evt_set *future_evt_set = nullptr;
-xbt_dynar_t surf_path = nullptr;
+std::vector<std::string> surf_path;
std::vector<simgrid::s4u::Host*> host_that_restart;
xbt_dict_t watched_hosts_lib;
FILE *surf_fopen(const char *name, const char *mode)
{
- unsigned int cpt;
- char *path_elm = nullptr;
char *buff;
FILE *file = nullptr;
return fopen(name, mode);
/* search relative files in the path */
- xbt_dynar_foreach(surf_path, cpt, path_elm) {
- buff = bprintf("%s" FILE_DELIM "%s", path_elm, name);
+ for (auto path_elm : surf_path) {
+ buff = bprintf("%s" FILE_DELIM "%s", path_elm.c_str(), name);
file = fopen(buff, mode);
free(buff);
{
TRACE_end(); /* Just in case it was not called by the upper layer (or there is no upper layer) */
- xbt_dynar_free(&surf_path);
-
sg_host_exit();
xbt_lib_free(&storage_lib);
sg_link_exit();
extern XBT_PRIVATE double sg_bandwidth_factor;
extern XBT_PRIVATE double sg_weight_S_parameter;
extern XBT_PRIVATE int sg_network_crosstraffic;
-extern XBT_PRIVATE xbt_dynar_t surf_path;
+extern XBT_PRIVATE std::vector<std::string> surf_path;
extern "C" {
XBT_PUBLIC(double) surf_get_clock(void);
#include "xbt/str.h"
#include "xbt/dict.h"
#include "src/surf/trace_mgr.hpp"
+#include "src/surf/surf_interface.hpp"
#include "surf_private.h"
#include "xbt/RngStream.h"
#include <math.h>
#include <unordered_map>
+#include <boost/algorithm/string/join.hpp>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_trace, surf, "Surf trace management");
xbt_assert(trace_list.find(filename) == trace_list.end(), "Refusing to define trace %s twice", filename);
FILE *f = surf_fopen(filename, "r");
- xbt_assert(f != nullptr,
- "Cannot open file '%s' (path=%s)", filename, xbt_str_join(surf_path, ":"));
+ xbt_assert(f != nullptr, "Cannot open file '%s' (path=%s)", filename, (boost::join(surf_path, ":")).c_str());
char *tstr = xbt_str_from_file(f);
fclose(f);
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);
- xbt_dynar_push(surf_path, &dir);
+ char* dir = xbt_dirname(file);
+ surf_path.push_back(std::string(dir));
+ xbt_free(dir);
surf_file_to_parse = surf_fopen(file, "r");
xbt_assert((surf_file_to_parse), "Unable to open \"%s\"\n", file);
void surf_parse_close()
{
if (surf_parsed_filename) {
- char *dir = nullptr;
- xbt_dynar_pop(surf_path, &dir);
- free(dir);
+ surf_path.pop_back();
}
free(surf_parsed_filename);