Change breakpoint::filter to be a unique_xmalloc_ptr

Message ID 20190730190248.20709-1-tromey@adacore.com
State New, archived
Headers

Commit Message

Tom Tromey July 30, 2019, 7:02 p.m. UTC
  This changes breakpoint::filter to be a unique_xmalloc_ptr, removing
an explicit xfree, as well as a use of a "release" method.

gdb/ChangeLog
2019-07-30  Tom Tromey  <tromey@adacore.com>

	* breakpoint.c (init_breakpoint_sal): Update.
	(breakpoint): Update.
	* breakpoint.h (struct breakpoint) <filter>: Now a
	unique_xmalloc_ptr.
---
 gdb/ChangeLog    | 7 +++++++
 gdb/breakpoint.c | 5 ++---
 gdb/breakpoint.h | 5 ++---
 3 files changed, 11 insertions(+), 6 deletions(-)
  

Comments

Tom Tromey Aug. 6, 2019, 2 p.m. UTC | #1
>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:

Tom> This changes breakpoint::filter to be a unique_xmalloc_ptr, removing
Tom> an explicit xfree, as well as a use of a "release" method.

Tom> gdb/ChangeLog
Tom> 2019-07-30  Tom Tromey  <tromey@adacore.com>

Tom> 	* breakpoint.c (init_breakpoint_sal): Update.
Tom> 	(breakpoint): Update.
Tom> 	* breakpoint.h (struct breakpoint) <filter>: Now a
Tom> 	unique_xmalloc_ptr.

I'm checking this in now.

Tom
  

Patch

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index e0c9aa460f1..7a1e7824f21 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -8850,7 +8850,7 @@  init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
     b->location = std::move (location);
   else
     b->location = new_address_location (b->loc->address, NULL, 0);
-  b->filter = filter.release ();
+  b->filter = std::move (filter);
 }
 
 static void
@@ -12124,7 +12124,6 @@  breakpoint::~breakpoint ()
 {
   xfree (this->cond_string);
   xfree (this->extra_string);
-  xfree (this->filter);
 }
 
 static struct bp_location *
@@ -13701,7 +13700,7 @@  decode_location_default (struct breakpoint *b,
 
   decode_line_full (location, DECODE_LINE_FUNFIRSTLINE, search_pspace,
 		    NULL, 0, &canonical, multiple_symbols_all,
-		    b->filter);
+		    b->filter.get ());
 
   /* We should get 0 or 1 resulting SALs.  */
   gdb_assert (canonical.lsals.size () < 2);
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index a825be72228..69a043c7676 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -734,9 +734,8 @@  struct breakpoint
   event_location_up location;
 
   /* The filter that should be passed to decode_line_full when
-     re-setting this breakpoint.  This may be NULL, but otherwise is
-     allocated with xmalloc.  */
-  char *filter = NULL;
+     re-setting this breakpoint.  This may be NULL.  */
+  gdb::unique_xmalloc_ptr<char> filter;
 
   /* For a ranged breakpoint, the location we used to find the end of
      the range.  */