This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/3] Replace remaining cleanups in fbsd-nat.c.


Hi John,

@@ -84,20 +92,17 @@ fbsd_find_memory_regions (struct target_ops *self,
 			  find_memory_region_ftype func, void *obfd)
 {
   pid_t pid = ptid_get_pid (inferior_ptid);
-  struct kinfo_vmentry *vmentl, *kve;
+  struct kinfo_vmentry *kve;
   uint64_t size;
-  struct cleanup *cleanup;
   int i, nitems;

-  vmentl = kinfo_getvmmap (pid, &nitems);
+ std::unique_ptr<struct kinfo_vmentry, free_deleter<struct kinfo_vmentry>>
+    vmentl (kinfo_getvmmap (pid, &nitems));

Doesn't this essentially do the same thing as gdb::unique_xmalloc_ptr, since xfree calls free?

@@ -392,7 +392,7 @@ fbsd_xfer_partial (struct target_ops *ops, enum
target_object object,
 #endif
     case TARGET_OBJECT_AUXV:
       {
-	struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
+	gdb::unique_xmalloc_ptr<unsigned char> buf_storage(nullptr);

You don't need to initialize explicitly to nullptr, that's the default value. But if you still want to, then add a space before parenthesis :).

Otherwise, gdb::byte_vector with a .resize() would probably be appropriate to use here.

Thanks,

Simon


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]