]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: remove decref_target
authorAndrew Burgess <aburgess@redhat.com>
Thu, 22 Sep 2022 18:10:52 +0000 (19:10 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Wed, 14 Dec 2022 13:57:22 +0000 (13:57 +0000)
The decref_target function is not really needed.  Calling
target_ops::decref will just redirect to decref_target anyway, so why
not just rename decref_target to target_ops::decref?

That's what this commit does.

It's not exactly renaming to target_ops::decref, because the decref
functionality is handled by a policy class, so the new name is now
target_ops_ref_policy::decref.

There should be no user visible change after this commit.

gdb/target.c
gdb/target.h

index b3fd2345b78e1541b54468635925e1382f2a64cc..417d384a67ea3cd6c3888f8fff3e76511be7c62f 100644 (file)
@@ -1166,7 +1166,7 @@ to_execution_direction must be implemented for reverse async");
 /* See target.h.  */
 
 void
-decref_target (target_ops *t)
+target_ops_ref_policy::decref (target_ops *t)
 {
   t->decref ();
   if (t->refcount () == 0)
index b9888f851cc04f04007d063834deca391737e407..68446a39c1b457b79249452312e24132e9eeb6c4 100644 (file)
@@ -1337,9 +1337,6 @@ struct target_ops_deleter
 /* A unique pointer for target_ops.  */
 typedef std::unique_ptr<target_ops, target_ops_deleter> target_ops_up;
 
-/* Decref a target and close if, if there are no references left.  */
-extern void decref_target (target_ops *t);
-
 /* A policy class to interface gdb::ref_ptr with target_ops.  */
 
 struct target_ops_ref_policy
@@ -1349,10 +1346,9 @@ struct target_ops_ref_policy
     t->incref ();
   }
 
-  static void decref (target_ops *t)
-  {
-    decref_target (t);
-  }
+  /* Decrement the reference count on T, and, if the reference count
+     reaches zero, close the target.  */
+  static void decref (target_ops *t);
 };
 
 /* A gdb::ref_ptr pointer to a target_ops.  */