This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

Re: [PATCH] Call memcpy in generic mempcpy


On 02/07/2013 08:54 PM, OndÅej BÃlka wrote:
On Wed, Feb 06, 2013 at 03:19:37PM -0800, Roland McGrath wrote:
On 02/06/13 12:53, Ond$,1 yej B,Amlka wrote:
unsigned long int dstp = (long int) dstpp;
...
+  memcpy (dstpp, srcpp, len);
+  return (void *) (dstp + len);

There's no need to use an integer type, or to do any casts. Something like this, perhaps?

   char *dstp = dstpp;
   memcpy (destpp, srcpp, len);
   return dstp + len;

It's GNU code and can assume GNU C extensions. So there isn't even a need for a cast. And, it's more efficient to use the return value.
OK.

I also renamed dstpp to dest as that distinction is no longer needed.

2013-02-06 OndÅej BÃlka <neleai@seznam.cz>

* string/mempcpy.c: Implement by calling memcpy.

diff --git a/string/mempcpy.c b/string/mempcpy.c
index ba4d1c6..e1aad75 100644
--- a/string/mempcpy.c
+++ b/string/mempcpy.c
@@ -20,48 +20,17 @@
     <http://www.gnu.org/licenses/>.  */

  #include <string.h>
-#include <memcopy.h>
-#include <pagecopy.h>

  #undef mempcpy
  #undef __mempcpy

  void *
-__mempcpy (dstpp, srcpp, len)
-     void *dstpp;
-     const void *srcpp;
+__mempcpy (dest, src, len)
+     void *dest;
+     const void *src;
       size_t len;

Shouldn't this be: __mempcpy (void dest, const void *src, size_t len) ? We're converting the code to get rid of the old prototypes.


Andreas
--
 Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
  SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 NÃrnberg, Germany
   GF: Jeff Hawn,Jennifer Guild,Felix ImendÃrffer,HRB16746 (AG NÃrnberg)
    GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126


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