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]

[RFA] remove unnecessary alloca/memcpy in write_memory


Hi.  Any ideas why the call to alloca/memcpy?
[Why not pass myaddr to target_write_memory directly?]

void
write_memory (CORE_ADDR memaddr, const bfd_byte *myaddr, int len)
{
  int status;
  gdb_byte *bytes = alloca (len);
  
  memcpy (bytes, myaddr, len);
  status = target_write_memory (memaddr, bytes, len);
  if (status != 0)
    memory_error (status, memaddr);
}

2008-08-05  Doug Evans  <dje@google.com>

	* corefile.c (write_memory): Remove unnecessary copying.

Index: corefile.c
===================================================================
RCS file: /cvs/src/src/gdb/corefile.c,v
retrieving revision 1.44
diff -u -p -u -p -r1.44 corefile.c
--- corefile.c	30 Apr 2008 18:22:37 -0000	1.44
+++ corefile.c	6 Aug 2008 04:45:25 -0000
@@ -350,10 +350,7 @@ void
 write_memory (CORE_ADDR memaddr, const bfd_byte *myaddr, int len)
 {
   int status;
-  gdb_byte *bytes = alloca (len);
-  
-  memcpy (bytes, myaddr, len);
-  status = target_write_memory (memaddr, bytes, len);
+  status = target_write_memory (memaddr, myaddr, len);
   if (status != 0)
     memory_error (status, memaddr);
 }


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