[RFA 07/13] Use gdb::def_vector in sparc64-tdep.c

Tom Tromey
2017-11-02T22:36:23Z

This removes a cleanup from sparc64-tdep.c, replacing it with
gdb::def_vector.

gdb/ChangeLog
2017-11-02 Tom Tromey <tom@tromey.com>

* sparc64-tdep.c (do_examine): Use gdb::def_vector.
---
gdb/ChangeLog | 4 ++++
gdb/sparc64-tdep.c | 10 +++-------
2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index a756834cba..eebfbdf96f 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -415,21 +415,17 @@ static void
do_examine (CORE_ADDR start, int bcnt)
{
CORE_ADDR vaddr = adi_normalize_address (start);
- struct cleanup *cleanup;

CORE_ADDR vstart = adi_align_address (vaddr);
int cnt = adi_convert_byte_count (vaddr, bcnt, vstart);
- unsigned char *buf = (unsigned char *) xmalloc (cnt);
- cleanup = make_cleanup (xfree, buf);
- int read_cnt = adi_read_versions (vstart, cnt, buf);
+ gdb::def_vector<unsigned char> buf (cnt);
+ int read_cnt = adi_read_versions (vstart, cnt, buf.data ());
if (read_cnt == -1)
error (_("No ADI information"));
else if (read_cnt < cnt)
error(_("No ADI information at %s"), paddress (target_gdbarch (), vaddr));

- adi_print_versions (vstart, cnt, buf);
-
- do_cleanups (cleanup);
+ adi_print_versions (vstart, cnt, buf.data ());
}

static void
--
2.13.6