This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Class-ify lm_info_dsbt


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b091120773f8a740065b6449617cfbf1e0e789f4

commit b091120773f8a740065b6449617cfbf1e0e789f4
Author: Simon Marchi <simon.marchi@ericsson.com>
Date:   Fri Apr 28 17:16:14 2017 -0400

    Class-ify lm_info_dsbt
    
    This patches makes lm_info_dsbt a "real" class.  It introduces a
    destructor, initializes the field and replaces XCNEW/xfree with
    new/delete.
    
    gdb/ChangeLog:
    
    	* solib-dsbt.c (struct lm_info_dsbt): Add destructor, initialize
    	map field.
    	(dsbt_current_sos): Allocate lm_info_dsbt with new.
    	(dsbt_relocate_main_executable): Free lm_info_dsbt with delete
    	and allocate with new.
    	(dsbt_clear_solib, dsbt_free_so): Free lm_info_dsbt with delete.

Diff:
---
 gdb/ChangeLog    |  9 +++++++++
 gdb/solib-dsbt.c | 25 +++++++++++++------------
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6fb632b..ae004eb 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,14 @@
 2017-04-28  Simon Marchi  <simon.marchi@ericsson.com>
 
+	* solib-dsbt.c (struct lm_info_dsbt): Add destructor, initialize
+	map field.
+	(dsbt_current_sos): Allocate lm_info_dsbt with new.
+	(dsbt_relocate_main_executable): Free lm_info_dsbt with delete
+	and allocate with new.
+	(dsbt_clear_solib, dsbt_free_so): Free lm_info_dsbt with delete.
+
+2017-04-28  Simon Marchi  <simon.marchi@ericsson.com>
+
 	* solib-aix.c (struct lm_info_aix): Initialize fields in-class.
 	<filename, member_name>: Change type to std::string.
 	(solib_aix_new_lm_info, solib_aix_xfree_lm_info): Remove.
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index 6d410ac..facbd93 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -125,8 +125,13 @@ struct ext_link_map
 
 struct lm_info_dsbt : public lm_info_base
 {
+  ~lm_info_dsbt ()
+  {
+    xfree (this->map);
+  }
+
   /* The loadmap, digested into an easier to use form.  */
-  struct int_elf32_dsbt_loadmap *map;
+  int_elf32_dsbt_loadmap *map = NULL;
 };
 
 /* Per pspace dsbt specific data.  */
@@ -711,7 +716,7 @@ dsbt_current_sos (void)
 	    }
 
 	  sop = XCNEW (struct so_list);
-	  lm_info_dsbt *li = XCNEW (lm_info_dsbt);
+	  lm_info_dsbt *li = new lm_info_dsbt;
 	  sop->lm_info = li;
 	  li->map = loadmap;
 	  /* Fetch the name.  */
@@ -930,8 +935,8 @@ dsbt_relocate_main_executable (void)
   dsbt_get_initial_loadmaps ();
   ldm = info->exec_loadmap;
 
-  xfree (info->main_executable_lm_info);
-  info->main_executable_lm_info = XCNEW (lm_info_dsbt);
+  delete info->main_executable_lm_info;
+  info->main_executable_lm_info = new lm_info_dsbt;
   info->main_executable_lm_info->map = ldm;
 
   new_offsets = XCNEWVEC (struct section_offsets,
@@ -1006,12 +1011,9 @@ dsbt_clear_solib (void)
 
   info->lm_base_cache = 0;
   info->main_lm_addr = 0;
-  if (info->main_executable_lm_info != 0)
-    {
-      xfree (info->main_executable_lm_info->map);
-      xfree (info->main_executable_lm_info);
-      info->main_executable_lm_info = 0;
-    }
+
+  delete info->main_executable_lm_info;
+  info->main_executable_lm_info = NULL;
 }
 
 static void
@@ -1019,8 +1021,7 @@ dsbt_free_so (struct so_list *so)
 {
   lm_info_dsbt *li = (lm_info_dsbt *) so->lm_info;
 
-  xfree (li->map);
-  xfree (li);
+  delete li;
 }
 
 static void


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]