aboutsummaryrefslogtreecommitdiff
path: root/gdb/linespec.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-04-10 15:47:21 -0600
committerTom Tromey <tom@tromey.com>2017-04-12 11:16:19 -0600
commit16e802b9c085ce354b1ab9e2fd25d00bf7626fa8 (patch)
tree7745d7708fd31fe748a6807242a3a6e58201f892 /gdb/linespec.c
parentd28cd78ad820e3a40ac5064b6a30f3a12ce70bf0 (diff)
downloadgdb-16e802b9c085ce354b1ab9e2fd25d00bf7626fa8.zip
gdb-16e802b9c085ce354b1ab9e2fd25d00bf7626fa8.tar.gz
gdb-16e802b9c085ce354b1ab9e2fd25d00bf7626fa8.tar.bz2
Add a constructor and destructor to linespec_result
linespec_result is only ever allocated on the stack, so it's relatively easy to convert to having a constructor and a destructor. This patch makes this change. This removes some cleanups. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * linespec.h (struct linespec_result): Add constructor and destructor. (init_linespec_result, destroy_linespec_result) (make_cleanup_destroy_linespec_result): Don't declare. * linespec.c (init_linespec_result): Remove. (linespec_result::~linespec_result): Rename from destroy_linespec_result. Update. (cleanup_linespec_result, make_cleanup_destroy_linespec_result): Remove. * breakpoint.c (create_breakpoint, break_range_command) (decode_location_default): Update. * ax-gdb.c (agent_command_1): Update.
Diffstat (limited to 'gdb/linespec.c')
-rw-r--r--gdb/linespec.c35
1 files changed, 4 insertions, 31 deletions
diff --git a/gdb/linespec.c b/gdb/linespec.c
index bccabaf..51fa128 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -3887,45 +3887,18 @@ symbol_to_sal (struct symtab_and_line *result,
return 0;
}
-/* See the comment in linespec.h. */
-
-void
-init_linespec_result (struct linespec_result *lr)
-{
- memset (lr, 0, sizeof (*lr));
-}
-
-/* See the comment in linespec.h. */
-
-void
-destroy_linespec_result (struct linespec_result *ls)
+linespec_result::~linespec_result ()
{
int i;
struct linespec_sals *lsal;
- delete_event_location (ls->location);
- for (i = 0; VEC_iterate (linespec_sals, ls->sals, i, lsal); ++i)
+ delete_event_location (location);
+ for (i = 0; VEC_iterate (linespec_sals, sals, i, lsal); ++i)
{
xfree (lsal->canonical);
xfree (lsal->sals.sals);
}
- VEC_free (linespec_sals, ls->sals);
-}
-
-/* Cleanup function for a linespec_result. */
-
-static void
-cleanup_linespec_result (void *a)
-{
- destroy_linespec_result ((struct linespec_result *) a);
-}
-
-/* See the comment in linespec.h. */
-
-struct cleanup *
-make_cleanup_destroy_linespec_result (struct linespec_result *ls)
-{
- return make_cleanup (cleanup_linespec_result, ls);
+ VEC_free (linespec_sals, sals);
}
/* Return the quote characters permitted by the linespec parser. */