diff options
author | Tom Tromey <tom@tromey.com> | 2017-10-12 18:20:09 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-10-16 16:10:21 -0600 |
commit | 87028b873938aa3cc756c99e33a328640dbc30bc (patch) | |
tree | dfcd9d27e1c072452798930bc3b6f1b658f75e2c /gdb/sparc64-tdep.c | |
parent | b7b030adc405017f01e996a90f85e40730ef8397 (diff) | |
download | gdb-87028b873938aa3cc756c99e33a328640dbc30bc.zip gdb-87028b873938aa3cc756c99e33a328640dbc30bc.tar.gz gdb-87028b873938aa3cc756c99e33a328640dbc30bc.tar.bz2 |
Return unique_xmalloc_ptr from target_fileio_read_stralloc
Change target_fileio_read_stralloc to return unique_xmalloc_ptr and
fix up the callers. This removes a number of cleanups.
ChangeLog
2017-10-16 Tom Tromey <tom@tromey.com>
* linux-tdep.c (linux_info_proc, linux_find_memory_regions_full)
(linux_fill_prpsinfo, linux_vsyscall_range_raw): Update.
* target.c (target_fileio_read_stralloc): Update.
* sparc64-tdep.c (adi_is_addr_mapped): Update.
* target.h (target_fileio_read_stralloc): Return
unique_xmalloc_ptr.
Diffstat (limited to 'gdb/sparc64-tdep.c')
-rw-r--r-- | gdb/sparc64-tdep.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index 2fbeec0..6a1d963 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -311,13 +311,13 @@ adi_is_addr_mapped (CORE_ADDR vaddr, size_t cnt) pid_t pid = ptid_get_pid (inferior_ptid); snprintf (filename, sizeof filename, "/proc/%ld/adi/maps", (long) pid); - char *data = target_fileio_read_stralloc (NULL, filename); + gdb::unique_xmalloc_ptr<char> data + = target_fileio_read_stralloc (NULL, filename); if (data) { - struct cleanup *cleanup = make_cleanup (xfree, data); adi_stat_t adi_stat = get_adi_info (pid); char *line; - for (line = strtok (data, "\n"); line; line = strtok (NULL, "\n")) + for (line = strtok (data.get (), "\n"); line; line = strtok (NULL, "\n")) { ULONGEST addr, endaddr; @@ -327,13 +327,9 @@ adi_is_addr_mapped (CORE_ADDR vaddr, size_t cnt) && ((vaddr + i) * adi_stat.blksize) < endaddr) { if (++i == cnt) - { - do_cleanups (cleanup); - return true; - } + return true; } } - do_cleanups (cleanup); } else warning (_("unable to open /proc file '%s'"), filename); |