diff options
author | Tom Tromey <tom@tromey.com> | 2017-04-28 23:34:32 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-08-03 07:59:02 -0600 |
commit | 26fcd5d7572ea1bf0cc697158969749420900e0b (patch) | |
tree | 4fd942f6a9ce113d4c1733b77c3191c5fe679a47 /gdb/valops.c | |
parent | 7c218e6c9c88cb8120adf1a7a530cfdec23aaf81 (diff) | |
download | gdb-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/valops.c')
-rw-r--r-- | gdb/valops.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/gdb/valops.c b/gdb/valops.c index 8675e6c..3668f0b 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -39,6 +39,7 @@ #include "observer.h" #include "objfiles.h" #include "extension.h" +#include "byte-vector.h" extern unsigned int overload_debug; /* Local functions. */ @@ -2076,24 +2077,20 @@ search_struct_method (const char *name, struct value **arg1p, if (offset < 0 || offset >= TYPE_LENGTH (type)) { - gdb_byte *tmp; - struct cleanup *back_to; CORE_ADDR address; - tmp = (gdb_byte *) xmalloc (TYPE_LENGTH (baseclass)); - back_to = make_cleanup (xfree, tmp); + gdb::byte_vector tmp (TYPE_LENGTH (baseclass)); address = value_address (*arg1p); if (target_read_memory (address + offset, - tmp, TYPE_LENGTH (baseclass)) != 0) + tmp.data (), TYPE_LENGTH (baseclass)) != 0) error (_("virtual baseclass botch")); base_val = value_from_contents_and_address (baseclass, - tmp, + tmp.data (), address + offset); base_valaddr = value_contents_for_printing (base_val); this_offset = 0; - do_cleanups (back_to); } else { |