aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2018-01-09 13:35:17 -0800
committerJohn Baldwin <jhb@FreeBSD.org>2018-01-09 13:35:17 -0800
commit262f62f57d987269152412a55c458a03adc6ddd6 (patch)
treeff23df9bda29d6567d72d1640e0c4b6dc27660ff
parentb999e2038dbc54e2c8b1c390f8b8fe50d0f1d10a (diff)
downloadgdb-262f62f57d987269152412a55c458a03adc6ddd6.zip
gdb-262f62f57d987269152412a55c458a03adc6ddd6.tar.gz
gdb-262f62f57d987269152412a55c458a03adc6ddd6.tar.bz2
Use gdb::unique_xmalloc_ptr<> instead of a deleter that invokes free().
Since xfree() always wraps free(), it is safe to use the xfree deleter for buffers allocated by library routines such as kinfo_getvmmap() that must be released via free(). gdb/ChangeLog: * fbsd-nat.c (struct free_deleter): Remove. (fbsd_find_memory_regions): Use gdb::unique_xmalloc_ptr<>.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/fbsd-nat.c10
2 files changed, 6 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 3752a3b..a55b21f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2018-01-09 John Baldwin <jhb@FreeBSD.org>
+ * fbsd-nat.c (struct free_deleter): Remove.
+ (fbsd_find_memory_regions): Use gdb::unique_xmalloc_ptr<>.
+
+2018-01-09 John Baldwin <jhb@FreeBSD.org>
+
* fbsd-nat.c (fbsd_pid_to_exec_file) [KERN_PROC_PATHNAME]: Return
NULL for an empty pathname.
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index d0aaf89..81f8e27 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -81,14 +81,6 @@ fbsd_pid_to_exec_file (struct target_ops *self, int pid)
}
#ifdef HAVE_KINFO_GETVMMAP
-/* Deleter for std::unique_ptr that invokes free. */
-
-template <typename T>
-struct free_deleter
-{
- void operator() (T *ptr) const { free (ptr); }
-};
-
/* Iterate over all the memory regions in the current inferior,
calling FUNC for each memory region. OBFD is passed as the last
argument to FUNC. */
@@ -102,7 +94,7 @@ fbsd_find_memory_regions (struct target_ops *self,
uint64_t size;
int i, nitems;
- std::unique_ptr<struct kinfo_vmentry, free_deleter<struct kinfo_vmentry>>
+ gdb::unique_xmalloc_ptr<struct kinfo_vmentry>
vmentl (kinfo_getvmmap (pid, &nitems));
if (vmentl == NULL)
perror_with_name (_("Couldn't fetch VM map entries."));