Back to index

cell-binutils  2.17cvs20070401
bcopy.c
Go to the documentation of this file.
00001 /* bcopy -- copy memory regions of arbitary length
00002 
00003 @deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length})
00004 
00005 Copies @var{length} bytes from memory region @var{in} to region
00006 @var{out}.  The use of @code{bcopy} is deprecated in new programs.
00007 
00008 @end deftypefn
00009 
00010 */
00011 
00012 #include <stddef.h>
00013 
00014 void
00015 bcopy (const void *src, void *dest, size_t len)
00016 {
00017   if (dest < src)
00018     {
00019       const char *firsts = (const char *) src;
00020       char *firstd = (char *) dest;
00021       while (len--)
00022        *firstd++ = *firsts++;
00023     }
00024   else
00025     {
00026       const char *lasts = (const char *)src + (len-1);
00027       char *lastd = (char *)dest + (len-1);
00028       while (len--)
00029         *lastd-- = *lasts--;
00030     }
00031 }