Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Give ctor/dtor for s_dw_type
authorGabriel Corona <gabriel.corona@loria.fr>
Mon, 8 Jun 2015 21:31:55 +0000 (23:31 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 9 Jun 2015 08:20:45 +0000 (10:20 +0200)
src/mc/mc_dwarf.cpp
src/mc/mc_object_info.h

index 4369550..f2c702e 100644 (file)
@@ -559,7 +559,7 @@ static void MC_dwarf_fill_member_location(dw_type_t type, dw_type_t member,
 
 static void dw_type_free_voidp(void *t)
 {
 
 static void dw_type_free_voidp(void *t)
 {
-  dw_type_free((dw_type_t) * (void **) t);
+  delete *(dw_type_t*)t;
 }
 
 /** \brief Populate the list of members of a type
 }
 
 /** \brief Populate the list of members of a type
@@ -639,7 +639,7 @@ static dw_type_t MC_dwarf_die_to_type(mc_object_info_t info, Dwarf_Die * die,
                                       const char *ns)
 {
 
                                       const char *ns)
 {
 
-  dw_type_t type = xbt_new0(s_dw_type_t, 1);
+  dw_type_t type = new s_dw_type();
   type->type = -1;
   type->id = 0;
   type->name = NULL;
   type->type = -1;
   type->id = 0;
   type->name = NULL;
@@ -1072,13 +1072,21 @@ void mc_frame_free(dw_frame_t frame)
   xbt_free(frame);
 }
 
   xbt_free(frame);
 }
 
-void dw_type_free(dw_type_t t)
+s_dw_type::s_dw_type()
 {
 {
-  xbt_free(t->name);
-  xbt_free(t->dw_type_id);
-  xbt_dynar_free(&(t->members));
-  mc_dwarf_expression_clear(&t->location);
-  xbt_free(t);
+}
+
+s_dw_type::~s_dw_type()
+{
+  xbt_free(this->name);
+  xbt_free(this->dw_type_id);
+  xbt_dynar_free(&this->members);
+  mc_dwarf_expression_clear(&this->location);
+}
+
+static void dw_type_free(dw_type_t t)
+{
+  delete t;
 }
 
 void dw_variable_free(dw_variable_t v)
 }
 
 void dw_variable_free(dw_variable_t v)
index 4843d33..4c02bca 100644 (file)
@@ -30,24 +30,26 @@ SG_BEGIN_DECL();
 typedef int e_dw_type_type;
 
 struct s_dw_type {
 typedef int e_dw_type_type;
 
 struct s_dw_type {
-  e_dw_type_type type;
-  Dwarf_Off id; /* Offset in the section (in hexadecimal form) */
-  char *name; /* Name of the type */
-  int byte_size; /* Size in bytes */
-  int element_count; /* Number of elements for array type */
-  char *dw_type_id; /* DW_AT_type id */
-  xbt_dynar_t members; /* if DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type*/
-  int is_pointer_type;
+  s_dw_type();
+  ~s_dw_type();
+
+  e_dw_type_type type = 0;
+  Dwarf_Off id = 0; /* Offset in the section (in hexadecimal form) */
+  char *name = nullptr; /* Name of the type */
+  int byte_size = 0; /* Size in bytes */
+  int element_count = 0; /* Number of elements for array type */
+  char *dw_type_id = nullptr; /* DW_AT_type id */
+  xbt_dynar_t members = nullptr; /* if DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type*/
+  int is_pointer_type = 0;
 
   // Location (for members) is either of:
 
   // Location (for members) is either of:
-  struct s_mc_expression location;
-  int offset;
+  struct s_mc_expression location = { 0, 0, 0, 0 };
+  int offset = 0;
 
 
-  dw_type_t subtype; // DW_AT_type
-  dw_type_t full_type; // The same (but more complete) type
+  dw_type_t subtype = nullptr; // DW_AT_type
+  dw_type_t full_type = nullptr; // The same (but more complete) type
 };
 
 };
 
-XBT_INTERNAL void dw_type_free(dw_type_t t);
 XBT_INTERNAL void dw_variable_free(dw_variable_t v);
 XBT_INTERNAL void dw_variable_free_voidp(void *t);
 
 XBT_INTERNAL void dw_variable_free(dw_variable_t v);
 XBT_INTERNAL void dw_variable_free_voidp(void *t);