[RFA] remove unnecessary alloca/memcpy in write_memory
Doug Evans
dje@google.com
Wed Aug 6 04:48:00 GMT 2008
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);
}
More information about the Gdb-patches
mailing list