root/maint/gnulib/lib/memmove.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. memmove

   1 /* memmove.c -- copy memory.
   2    This file is in the public domain.  */
   3 
   4 /* Written by David MacKenzie <djm@gnu.ai.mit.edu>.  */
   5 
   6 #include <config.h>
   7 
   8 #include <stddef.h>
   9 
  10 /* Copy LENGTH bytes from SOURCE to DEST.  Does not null-terminate.  */
  11 
  12 void *
  13 memmove (void *dest0, void const *source0, size_t length)
     /* [previous][next][first][last][top][bottom][index][help] */
  14 {
  15   char *dest = dest0;
  16   char const *source = source0;
  17   if (source < dest)
  18     /* Moving from low mem to hi mem; start at end.  */
  19     for (source += length, dest += length; length; --length)
  20       *--dest = *--source;
  21   else if (source != dest)
  22     {
  23       /* Moving from hi mem to low mem; start at beginning.  */
  24       for (; length; --length)
  25         *dest++ = *source++;
  26     }
  27   return dest0;
  28 }

/* [previous][next][first][last][top][bottom][index][help] */