From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8971 invoked by alias); 6 Aug 2008 04:48:02 -0000 Received: (qmail 8917 invoked by uid 22791); 6 Aug 2008 04:48:01 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 06 Aug 2008 04:47:26 +0000 Received: from zps37.corp.google.com (zps37.corp.google.com [172.25.146.37]) by smtp-out.google.com with ESMTP id m764lKFk031545 for ; Wed, 6 Aug 2008 05:47:20 +0100 Received: from localhost (ruffy.corp.google.com [172.18.118.116]) by zps37.corp.google.com with ESMTP id m764lIAM030410 for ; Tue, 5 Aug 2008 21:47:19 -0700 Received: by localhost (Postfix, from userid 67641) id E1D301C77BE; Tue, 5 Aug 2008 21:47:18 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [RFA] remove unnecessary alloca/memcpy in write_memory Message-Id: <20080806044718.E1D301C77BE@localhost> Date: Wed, 06 Aug 2008 04:48:00 -0000 From: dje@google.com (Doug Evans) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-08/txt/msg00099.txt.bz2 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 * 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); }