aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-04-28 23:34:32 -0600
committerTom Tromey <tom@tromey.com>2017-08-03 07:59:02 -0600
commit26fcd5d7572ea1bf0cc697158969749420900e0b (patch)
tree4fd942f6a9ce113d4c1733b77c3191c5fe679a47 /gdb/mi
parent7c218e6c9c88cb8120adf1a7a530cfdec23aaf81 (diff)
downloadgdb-26fcd5d7572ea1bf0cc697158969749420900e0b.zip
gdb-26fcd5d7572ea1bf0cc697158969749420900e0b.tar.gz
gdb-26fcd5d7572ea1bf0cc697158969749420900e0b.tar.bz2
Use containers to avoid cleanups
This patch introduces the use of various containers -- std::vector, std::string, or gdb::byte_vector -- in several spots in gdb that were using xmalloc and a cleanup. ChangeLog 2017-08-03 Tom Tromey <tom@tromey.com> * valops.c (search_struct_method): Use gdb::byte_vector. * valarith.c (value_concat): Use std::vector. * target.c (memory_xfer_partial): Use gdb::byte_vector. (simple_search_memory): Likewise. * printcmd.c (find_string_backward): Use gdb::byte_vector. * mi/mi-main.c (mi_cmd_data_write_memory): Use gdb::byte_vector. * gcore.c (gcore_copy_callback): Use gdb::byte_vector. * elfread.c (elf_rel_plt_read): Use std::string. * cp-valprint.c (cp_print_value): Use gdb::byte_vector. * cli/cli-dump.c (restore_section_callback): Use gdb::byte_vector.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-main.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index a4c6ec9..0bf587f 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1659,8 +1659,6 @@ mi_cmd_data_write_memory (const char *command, char **argv, int argc)
/* FIXME: ezannoni 2000-02-17 LONGEST could possibly not be big
enough when using a compiler other than GCC. */
LONGEST value;
- gdb_byte *buffer;
- struct cleanup *old_chain;
long offset = 0;
int oind = 0;
char *oarg;
@@ -1707,13 +1705,10 @@ mi_cmd_data_write_memory (const char *command, char **argv, int argc)
/* Get the value as a number. */
value = parse_and_eval_address (argv[3]);
/* Get the value into an array. */
- buffer = (gdb_byte *) xmalloc (word_size);
- old_chain = make_cleanup (xfree, buffer);
- store_signed_integer (buffer, word_size, byte_order, value);
+ gdb::byte_vector buffer (word_size);
+ store_signed_integer (buffer.data (), word_size, byte_order, value);
/* Write it down to memory. */
- write_memory_with_notification (addr, buffer, word_size);
- /* Free the buffer. */
- do_cleanups (old_chain);
+ write_memory_with_notification (addr, buffer.data (), word_size);
}
/* Implementation of the -data-write-memory-bytes command.