Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /* bcopy -- copy memory regions of arbitary length
  2.  
  3. @deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length})
  4.  
  5. Copies @var{length} bytes from memory region @var{in} to region
  6. @var{out}.  The use of @code{bcopy} is deprecated in new programs.
  7.  
  8. @end deftypefn
  9.  
  10. */
  11.  
  12. #include <stddef.h>
  13.  
  14. void
  15. bcopy (const void *src, void *dest, size_t len)
  16. {
  17.   if (dest < src)
  18.     {
  19.       const char *firsts = (const char *) src;
  20.       char *firstd = (char *) dest;
  21.       while (len--)
  22.         *firstd++ = *firsts++;
  23.     }
  24.   else
  25.     {
  26.       const char *lasts = (const char *)src + (len-1);
  27.       char *lastd = (char *)dest + (len-1);
  28.       while (len--)
  29.         *lastd-- = *lasts--;
  30.     }
  31. }
  32.