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<>.
+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
}
#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. */
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."));