[v2,57/58] gdbserver: simply copy the pointer in 'set_target_ops'

Message ID 2f9385ba380c2b61abe2b93dce1cd0926c5961d8.1581956647.git.tankut.baris.aktemur@intel.com
State New, archived
Headers

Commit Message

Tankut Baris Aktemur Feb. 17, 2020, 4:58 p.m. UTC
  From: Pedro Alves <palves@redhat.com>

The 'set_target_ops' function takes a target op vector and creates a
clone of it via XNEW and memcpy.  This is not necessary.  'the_target'
is a singleton, and the argument that is passed to 'set_target_ops' is
always the address of a global, static object.  Therefore, update the
implementation to simply copy the pointer.

gdbserver/ChangeLog:
2020-02-10  Pedro Alves  <palves@redhat.com>

	* target.cc (set_target_ops): Simply copy the given target pointer
	instead of creating a copy of the pointed object.
---
 gdbserver/target.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Patch

diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 4df1f9d4bd8..d0a7d36c868 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -270,8 +270,7 @@  target_supports_multi_process (void)
 void
 set_target_ops (process_stratum_target *target)
 {
-  the_target = XNEW (process_stratum_target);
-  memcpy (the_target, target, sizeof (*the_target));
+  the_target = target;
 }
 
 /* Convert pid to printable format.  */