This is the mail archive of the libc-alpha@sources.redhat.com 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]

Re: Should we remove all internal usages of bcopy/bzero?


On Sun, Sep 16, 2001 at 06:13:35PM -0700, Ulrich Drepper wrote:
> "H . J . Lu" <hjl@lucon.org> writes:
> 
> > There are a few internal usages of bcopy/bzero. Should we replace them
> > with memmove/memset?
> 
> bcopy: yes.  bzero: not really.  There shouldn't be many bcopy uses
> left.  And yes, there is a reason: one less PLT entry.
> 

Here is a patch.


H.J.
---
2001-09-17  H.J. Lu  <hjl@gnu.org>

	* hurd/hurdmalloc.c (bcopy): Removed.
	(realloc): Replace bcopy with memcpy.
	* hurd/path-lookup.c (file_name_path_scan): Likewise.
	* resolv/gethnamaddr.c (map_v4v6_address): Likewise.
	* sunrpc/rpcinfo.c (pmapdump): Likewise.

	* resolv/gethnamaddr.c (getanswer): Replace bcopy with memmove.
	(gethostbyaddr): Likewise.
	* sunrpc/rpcinfo.c (get_inet_address): Likewise.

Index: hurd/hurdmalloc.c
===================================================================
RCS file: /cvsroot/sglibc/sglibc/hurd/hurdmalloc.c,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 hurdmalloc.c
--- hurd/hurdmalloc.c	2001/04/12 04:04:16	1.1.1.2
+++ hurd/hurdmalloc.c	2001/09/17 17:49:21
@@ -1,8 +1,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#define bcopy(s,d,n)	memcpy ((d), (s), (n)) /* No overlap handling.  */
-
 #include "hurdmalloc.h"		/* XXX see that file */
 
 #include <mach.h>
@@ -422,8 +420,8 @@ realloc(old_base, new_size)
 	 */
 	new_base = malloc(new_size);
 	if (new_base)
-	  bcopy(old_base, new_base,
-		(int) (old_size < new_size ? old_size : new_size));
+	  memcpy (new_base, old_base,
+		  (int) (old_size < new_size ? old_size : new_size));
 
 	if (new_base || new_size == 0)
 	  /* Free OLD_BASE, but only if the malloc didn't fail.  */
Index: hurd/path-lookup.c
===================================================================
RCS file: /cvsroot/sglibc/sglibc/hurd/path-lookup.c,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 path-lookup.c
--- hurd/path-lookup.c	2001/07/23 22:14:18	1.1.1.2
+++ hurd/path-lookup.c	2001/09/17 17:49:21
@@ -55,10 +55,10 @@ file_name_path_scan (const char *file_na
 	  if (pfx_len == 0)
 	    pfxed_name[pfx_len++] = '.';
 	  else
-	    bcopy (path, pfxed_name, pfx_len);
+	    memcpy (pfxed_name, path, pfx_len);
 	  if (pfxed_name[pfx_len - 1] != '/')
 	    pfxed_name[pfx_len++] = '/';
-	  bcopy (file_name, pfxed_name + pfx_len, file_name_len + 1);
+	  memcpy (pfxed_name + pfx_len, file_name, file_name_len + 1);
 
 	  err = (*fun)(pfxed_name);
 	  if (err == 0)
Index: resolv/gethnamaddr.c
===================================================================
RCS file: /cvsroot/sglibc/sglibc/resolv/gethnamaddr.c,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 gethnamaddr.c
--- resolv/gethnamaddr.c	2001/08/16 15:15:19	1.1.1.2
+++ resolv/gethnamaddr.c	2001/09/17 17:49:23
@@ -441,7 +441,7 @@ getanswer(answer, anslen, qname, qtype)
 				cp += n;
 				continue;
 			}
-			bcopy(cp, *hap++ = bp, n);
+			memmove(*hap++ = bp, cp, n);
 			bp += n;
 			buflen -= n;
 			cp += n;
@@ -738,7 +738,7 @@ gethostbyaddr(addr, len, af)
 #endif /*SUNSECURITY*/
 	hp->h_addrtype = af;
 	hp->h_length = len;
-	bcopy(addr, host_addr, len);
+	memmove(host_addr, addr, len);
 	h_addr_ptrs[0] = (char *)host_addr;
 	h_addr_ptrs[1] = NULL;
 	if (af == AF_INET && (_res.options & RES_USE_INET6)) {
@@ -899,14 +899,14 @@ map_v4v6_address(src, dst)
 	int i;
 
 	/* Stash a temporary copy so our caller can update in place. */
-	bcopy(src, tmp, INADDRSZ);
+	memcpy(tmp, src, INADDRSZ);
 	/* Mark this ipv6 addr as a mapped ipv4. */
 	for (i = 0; i < 10; i++)
 		*p++ = 0x00;
 	*p++ = 0xff;
 	*p++ = 0xff;
 	/* Retrieve the saved copy and we're done. */
-	bcopy(tmp, (void*)p, INADDRSZ);
+	memcpy((void*)p, tmp, INADDRSZ);
 }
 
 static void
Index: sunrpc/rpcinfo.c
===================================================================
RCS file: /cvsroot/sglibc/sglibc/sunrpc/rpcinfo.c,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 rpcinfo.c
--- sunrpc/rpcinfo.c	2001/01/08 23:07:03	1.1.1.2
+++ sunrpc/rpcinfo.c	2001/09/17 17:49:23
@@ -542,8 +542,8 @@ pmapdump (argc, argv)
       bzero ((char *) &server_addr, sizeof server_addr);
       server_addr.sin_family = AF_INET;
       if ((hp = gethostbyname ("localhost")) != NULL)
-	bcopy (hp->h_addr, (caddr_t) & server_addr.sin_addr,
-	       hp->h_length);
+	memcpy ((caddr_t) & server_addr.sin_addr, hp->h_addr,
+		 hp->h_length);
       else
 	server_addr.sin_addr.s_addr = inet_addr ("0.0.0.0");
     }
@@ -733,7 +733,7 @@ get_inet_address (addr, host)
 		   host);
 	  exit (1);
 	}
-      bcopy (hp->h_addr, (char *) &addr->sin_addr, hp->h_length);
+      memmove ((char *) &addr->sin_addr, hp->h_addr, hp->h_length);
     }
   addr->sin_family = AF_INET;
 }


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