aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-09-24 20:56:12 -0600
committerTom Tromey <tom@tromey.com>2016-10-21 14:17:34 -0600
commit6fc31fc73b577fce960730d87ead9a25df6c2653 (patch)
tree8ec74cdb35f39b052e3884f45e2d7a650d4b212a /gdb
parent0e454242cc1527e49ad0ea795614ac94a083b68a (diff)
downloadgdb-6fc31fc73b577fce960730d87ead9a25df6c2653.zip
gdb-6fc31fc73b577fce960730d87ead9a25df6c2653.tar.gz
gdb-6fc31fc73b577fce960730d87ead9a25df6c2653.tar.bz2
Remove some cleanups in MI
This patch removes a couple of cleanups from MI by using gdb::unique_ptr. 2016-10-21 Tom Tromey <tom@tromey.com> * mi/mi-main.c (mi_cmd_data_read_memory): Use gdb::unique_ptr. Remove some cleanups.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/mi/mi-main.c11
2 files changed, 9 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 02e917d..88afc37 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2016-10-21 Tom Tromey <tom@tromey.com>
+ * mi/mi-main.c (mi_cmd_data_read_memory): Use gdb::unique_ptr.
+ Remove some cleanups.
+
+2016-10-21 Tom Tromey <tom@tromey.com>
+
* tui/tui-interp.c (tui_on_normal_stop, tui_on_signal_received)
(tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited)
(tui_on_no_history, tui_on_user_selected_context_changed):
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 1bc8241..3b071af 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1416,7 +1416,6 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
{
struct gdbarch *gdbarch = get_current_arch ();
struct ui_out *uiout = current_uiout;
- struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
CORE_ADDR addr;
long total_bytes, nr_cols, nr_rows;
char word_format;
@@ -1424,7 +1423,6 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
long word_size;
char word_asize;
char aschar;
- gdb_byte *mbuf;
int nr_bytes;
long offset = 0;
int oind = 0;
@@ -1509,13 +1507,13 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
/* Create a buffer and read it in. */
total_bytes = word_size * nr_rows * nr_cols;
- mbuf = XCNEWVEC (gdb_byte, total_bytes);
- make_cleanup (xfree, mbuf);
+
+ gdb::unique_ptr<gdb_byte[]> mbuf (new gdb_byte[total_bytes]);
/* Dispatch memory reads to the topmost target, not the flattened
current_target. */
nr_bytes = target_read (current_target.beneath,
- TARGET_OBJECT_MEMORY, NULL, mbuf,
+ TARGET_OBJECT_MEMORY, NULL, mbuf.get (),
addr, total_bytes);
if (nr_bytes <= 0)
error (_("Unable to read memory."));
@@ -1569,7 +1567,7 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
else
{
ui_file_rewind (stream);
- print_scalar_formatted (mbuf + col_byte, word_type, &opts,
+ print_scalar_formatted (&mbuf[col_byte], word_type, &opts,
word_asize, stream);
ui_out_field_stream (uiout, NULL, stream);
}
@@ -1596,7 +1594,6 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
}
do_cleanups (cleanup_stream);
}
- do_cleanups (cleanups);
}
void