Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use a proper destructor for the paje::value type
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 24 Jul 2017 20:44:15 +0000 (22:44 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 24 Jul 2017 20:44:15 +0000 (22:44 +0200)
src/instr/instr_paje_types.cpp
src/instr/instr_paje_values.cpp
src/instr/instr_private.h

index 494ef42..daa0d4e 100644 (file)
@@ -52,10 +52,7 @@ void PJ_type_free (type_t type)
   xbt_dict_cursor_t cursor = nullptr;
   xbt_dict_foreach (type->values, cursor, value_name, val) {
     XBT_DEBUG("free value %s, child of %s", val->name, val->father->name);
   xbt_dict_cursor_t cursor = nullptr;
   xbt_dict_foreach (type->values, cursor, value_name, val) {
     XBT_DEBUG("free value %s, child of %s", val->name, val->father->name);
-    xbt_free(val->name);
-    xbt_free(val->color);
-    xbt_free(val->id);
-    xbt_free(val);
+    delete val;
   }
   xbt_dict_free (&type->values);
   xbt_free (type->name);
   }
   xbt_dict_free (&type->values);
   xbt_free (type->name);
index 0eaefe2..f46eed5 100644 (file)
@@ -29,6 +29,13 @@ value::value(const char* name, const char* color, type_t father)
   LogEntityValue(this->ret);
 };
 
   LogEntityValue(this->ret);
 };
 
+value::~value()
+{
+  xbt_free(name);
+  xbt_free(color);
+  xbt_free(id);
+}
+
 value* value::get_or_new(const char* name, const char* color, type_t father)
 {
   value* ret = 0;
 value* value::get_or_new(const char* name, const char* color, type_t father)
 {
   value* ret = 0;
index a15dc2b..45bf123 100644 (file)
@@ -80,6 +80,7 @@ public:
   type_t father;
   value* ret;
   value(const char* name, const char* color, type_t father);
   type_t father;
   value* ret;
   value(const char* name, const char* color, type_t father);
+  ~value();
   static value* get_or_new(const char* name, const char* color, type_t father);
   static value* get(const char* name, type_t father);
 };
   static value* get_or_new(const char* name, const char* color, type_t father);
   static value* get(const char* name, type_t father);
 };