Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanup plugging a memleak
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 14 Sep 2017 12:46:13 +0000 (14:46 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 14 Sep 2017 12:46:18 +0000 (14:46 +0200)
src/instr/instr_interface.cpp
src/instr/instr_paje_types.cpp
src/instr/instr_paje_values.cpp
src/instr/instr_private.h
src/surf/instr_routing.cpp

index 3f079eb..f057311 100644 (file)
@@ -193,7 +193,7 @@ void TRACE_declare_mark_value_with_color (const char *mark_type, const char *mar
     mark_color = white;
 
   XBT_DEBUG("MARK,declare_value %s %s %s", mark_type, mark_value, mark_color);
-  simgrid::instr::Value rett(mark_value, mark_color, type);
+  new simgrid::instr::Value(mark_value, mark_color, type);
 }
 
 /** \ingroup TRACE_mark
index 2ee8970..73ce50e 100644 (file)
@@ -33,9 +33,7 @@ simgrid::instr::Type::Type(const char* typeNameBuff, const char* key, const char
   this->values_   = xbt_dict_new_homogeneous(nullptr);
   this->color_    = xbt_strdup(color);
 
-  char str_id[INSTR_DEFAULT_STR_SIZE];
-  snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id());
-  this->id_ = xbt_strdup(str_id);
+  this->id_ = bprintf("%lld", instr_new_paje_id());
 
   if (father != nullptr){
     xbt_dict_set(father->children_, key, this, nullptr);
index 066d77f..adefdcc 100644 (file)
@@ -15,18 +15,15 @@ simgrid::instr::Value::Value(const char* name, const char* color, simgrid::instr
   if (name == nullptr || father == nullptr){
     THROWF (tracing_error, 0, "can't create a value with a nullptr name (or a nullptr father)");
   }
-  this->ret_          = xbt_new0(Value, 1);
-  this->ret_->name_   = xbt_strdup(name);
-  this->ret_->father_ = father;
-  this->ret_->color_  = xbt_strdup(color);
+  this->name_   = xbt_strdup(name);
+  this->father_ = father;
+  this->color_  = xbt_strdup(color);
 
-  char str_id[INSTR_DEFAULT_STR_SIZE];
-  snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id());
-  this->ret_->id_ = xbt_strdup(str_id);
+  this->id_ = bprintf("%lld", instr_new_paje_id());
 
-  xbt_dict_set(father->values_, name, ret_, nullptr);
-  XBT_DEBUG("new value %s, child of %s", ret_->name_, ret_->father_->name_);
-  LogEntityValue(this->ret_);
+  xbt_dict_set(father->values_, name, this, nullptr);
+  XBT_DEBUG("new value %s, child of %s", name_, father_->name_);
+  LogEntityValue(this);
 };
 
 simgrid::instr::Value::~Value()
@@ -46,8 +43,7 @@ simgrid::instr::Value* simgrid::instr::Value::get_or_new(const char* name, const
     ret = Value::get(name, father);
   }
   catch(xbt_ex& e) {
-    Value rett(name, color, father);
-    ret = rett.ret_;
+    ret = new Value(name, color, father);
   }
   return ret;
 }
index d08f868..37c4443 100644 (file)
@@ -85,7 +85,6 @@ public:
   char* color_;
 
   Type* father_;
-  Value* ret_;
   Value(const char* name, const char* color, Type* father);
   ~Value();
   static Value* get_or_new(const char* name, const char* color, Type* father);
index d14300d..c9e513c 100644 (file)
@@ -264,7 +264,7 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
     if (msg_process == nullptr){
       msg_process                 = simgrid::instr::Type::containerNew("MSG_PROCESS", container->type_);
       simgrid::instr::Type* state = simgrid::instr::Type::stateNew("MSG_PROCESS_STATE", msg_process);
-      simgrid::instr::Value PJ_value("suspend", "1 0 1", state);
+      new simgrid::instr::Value("suspend", "1 0 1", state);
       simgrid::instr::Value::get_or_new("sleep", "1 1 0", state);
       simgrid::instr::Value::get_or_new("receive", "1 0 0", state);
       simgrid::instr::Value::get_or_new("send", "0 0 1", state);
@@ -279,7 +279,7 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
     if (msg_vm == nullptr){
       msg_vm                      = simgrid::instr::Type::containerNew("MSG_VM", container->type_);
       simgrid::instr::Type* state = simgrid::instr::Type::stateNew("MSG_VM_STATE", msg_vm);
-      simgrid::instr::Value PJ_value("suspend", "1 0 1", state);
+      new simgrid::instr::Value("suspend", "1 0 1", state);
       simgrid::instr::Value::get_or_new("sleep", "1 1 0", state);
       simgrid::instr::Value::get_or_new("receive", "1 0 0", state);
       simgrid::instr::Value::get_or_new("send", "0 0 1", state);
@@ -402,7 +402,7 @@ static void recursiveNewValueForUserStateType(const char* type_name, const char*
                                               simgrid::instr::Type* root)
 {
   if (not strcmp(root->name_, type_name)) {
-    simgrid::instr::Value PJ_value(val, color, root);
+    new simgrid::instr::Value(val, color, root);
   }
   xbt_dict_cursor_t cursor = nullptr;
   simgrid::instr::Type* child_type;