gdbserver: simply copy the pointer in 'set_target_ops'
authorPedro Alves <palves@redhat.com>
Mon, 17 Feb 2020 15:12:03 +0000 (16:12 +0100)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Thu, 20 Feb 2020 16:35:20 +0000 (17:35 +0100)
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-20  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/ChangeLog
gdbserver/target.cc

index 1cd9c91a8d32b29ef38577360969207cee5124e6..50528153c545971ebf7b5b801459f9dbd8ddd031 100644 (file)
@@ -1,3 +1,8 @@
+2020-02-20  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.
+
 2020-02-20  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
 
        Turn process_stratum_target's get_ipa_tdesc_idx op into a method
index 4df1f9d4bd8cd3bd2a3471e5eb729a9d6bcdd971..d0a7d36c86822959b4a4fd7a49297602bedb1aad 100644 (file)
@@ -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.  */
This page took 0.031057 seconds and 4 git commands to generate.