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_windows


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

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

    Class-ify lm_info_windows
    
    This patch makes lm_info_windows a "real" class.  It initializes the field
    and replaces XCNEW/xfree with new/delete.
    
    gdb/ChangeLog:
    
    	* windows-nat.c (struct lm_info_windows): Initialize field.
    	(windows_make_so): Allocate lm_info_windows with new.
    	(windows_free_so): Free lm_info_windows with delete.

Diff:
---
 gdb/ChangeLog     | 6 ++++++
 gdb/windows-nat.c | 9 +++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 49f8f0d..24768c4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
 2017-04-28  Simon Marchi  <simon.marchi@ericsson.com>
 
+	* windows-nat.c (struct lm_info_windows): Initialize field.
+	(windows_make_so): Allocate lm_info_windows with new.
+	(windows_free_so): Free lm_info_windows with delete.
+
+2017-04-28  Simon Marchi  <simon.marchi@ericsson.com>
+
 	* solib-darwin.c (struct lm_info_darwin): Initialize field.
 	(darwin_current_sos): Allocate lm_info_darwin with new, remove
 	cleanup.
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index ef1c291..6a5a295 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -587,7 +587,7 @@ struct safe_symbol_file_add_args
 /* Maintain a linked list of "so" information.  */
 struct lm_info_windows : public lm_info_base
 {
-  LPVOID load_addr;
+  LPVOID load_addr = 0;
 };
 
 static struct so_list solib_start, *solib_end;
@@ -645,7 +645,7 @@ windows_make_so (const char *name, LPVOID load_addr)
     }
 #endif
   so = XCNEW (struct so_list);
-  lm_info_windows *li = XCNEW (struct lm_info_windows);
+  lm_info_windows *li = new lm_info_windows;
   so->lm_info = li;
   li->load_addr = load_addr;
   strcpy (so->so_original_name, name);
@@ -784,8 +784,9 @@ handle_load_dll (void *dummy)
 static void
 windows_free_so (struct so_list *so)
 {
-  if (so->lm_info)
-    xfree (so->lm_info);
+  lm_info_windows *li = (lm_info_windows *) so->lm_info;
+
+  delete li;
   xfree (so);
 }


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