From 7eed757b0efb54a58b781ea4a8c963f0b6321b92 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 24 Jul 2017 22:44:15 +0200 Subject: [PATCH] use a proper destructor for the paje::value type --- src/instr/instr_paje_types.cpp | 5 +---- src/instr/instr_paje_values.cpp | 7 +++++++ src/instr/instr_private.h | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/instr/instr_paje_types.cpp b/src/instr/instr_paje_types.cpp index 494ef42947..daa0d4eaf7 100644 --- a/src/instr/instr_paje_types.cpp +++ b/src/instr/instr_paje_types.cpp @@ -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_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); diff --git a/src/instr/instr_paje_values.cpp b/src/instr/instr_paje_values.cpp index 0eaefe26fe..f46eed5dd2 100644 --- a/src/instr/instr_paje_values.cpp +++ b/src/instr/instr_paje_values.cpp @@ -29,6 +29,13 @@ value::value(const char* name, const char* color, type_t father) 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; diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index a15dc2b6f2..45bf1235f2 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -80,6 +80,7 @@ public: 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); }; -- 2.20.1