aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-05-04 15:44:27 -0600
committerTom Tromey <tom@tromey.com>2017-09-29 21:12:15 -0600
commit45d288cc64e08dd68938f1d9bcc70906b5343652 (patch)
tree39c81c7edfb2b6a5f055e6156cf2376d5423dcaa /gdb/mi
parent6afe2f4a39badf0ea1ccf9fd34417e729577c6e6 (diff)
downloadgdb-45d288cc64e08dd68938f1d9bcc70906b5343652.zip
gdb-45d288cc64e08dd68938f1d9bcc70906b5343652.tar.gz
gdb-45d288cc64e08dd68938f1d9bcc70906b5343652.tar.bz2
Use gdb::byte_vector in mi_cmd_data_write_memory_bytes
This changes mi_cmd_data_write_memory_bytes to use gdb::byte_vector, removing some cleanups. gdb/ChangeLog 2017-09-29 Tom Tromey <tom@tromey.com> * mi/mi-main.c (mi_cmd_data_write_memory_bytes): Use gdb::byte_vector.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-main.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 5e71949..e1ba8e2 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1715,11 +1715,8 @@ mi_cmd_data_write_memory_bytes (const char *command, char **argv, int argc)
{
CORE_ADDR addr;
char *cdata;
- gdb_byte *data;
- gdb_byte *databuf;
size_t len_hex, len_bytes, len_units, i, steps, remaining_units;
long int count_units;
- struct cleanup *back_to;
int unit_size;
if (argc != 2 && argc != 3)
@@ -1743,8 +1740,7 @@ mi_cmd_data_write_memory_bytes (const char *command, char **argv, int argc)
else
count_units = len_units;
- databuf = XNEWVEC (gdb_byte, len_bytes);
- back_to = make_cleanup (xfree, databuf);
+ gdb::byte_vector databuf (len_bytes);
for (i = 0; i < len_bytes; ++i)
{
@@ -1754,34 +1750,32 @@ mi_cmd_data_write_memory_bytes (const char *command, char **argv, int argc)
databuf[i] = (gdb_byte) x;
}
+ gdb::byte_vector data;
if (len_units < count_units)
{
/* Pattern is made of less units than count:
repeat pattern to fill memory. */
- data = (gdb_byte *) xmalloc (count_units * unit_size);
- make_cleanup (xfree, data);
+ data = gdb::byte_vector (count_units * unit_size);
/* Number of times the pattern is entirely repeated. */
steps = count_units / len_units;
/* Number of remaining addressable memory units. */
remaining_units = count_units % len_units;
for (i = 0; i < steps; i++)
- memcpy (data + i * len_bytes, databuf, len_bytes);
+ memcpy (&data[i * len_bytes], &databuf[0], len_bytes);
if (remaining_units > 0)
- memcpy (data + steps * len_bytes, databuf,
+ memcpy (&data[steps * len_bytes], &databuf[0],
remaining_units * unit_size);
}
else
{
/* Pattern is longer than or equal to count:
just copy count addressable memory units. */
- data = databuf;
+ data = std::move (databuf);
}
- write_memory_with_notification (addr, data, count_units);
-
- do_cleanups (back_to);
+ write_memory_with_notification (addr, data.data (), count_units);
}
void