view lib/memmove.c @ 20334:f9629a6448bc

Return a value!
author Jim Meyering <jim@meyering.net>
date Sun, 14 Jul 1996 15:05:40 +0000
parents 1ce891ef6ac0
children 221d11a2cacd
line wrap: on
line source

/* memmove.c -- copy memory.
   Copy LENGTH bytes from SOURCE to DEST.  Does not null-terminate.
   In the public domain.
   By David MacKenzie <djm@gnu.ai.mit.edu>.  */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

void *
memmove (dest, source, length)
     char *dest;
     const char *source;
     unsigned length;
{
  if (source < dest)
    /* Moving from low mem to hi mem; start at end.  */
    for (source += length, dest += length; length; --length)
      *--dest = *--source;
  else if (source != dest)
    {
      /* Moving from hi mem to low mem; start at beginning.  */
      for (; length; --length)
	*dest++ = *source++;
      --dest;
    }
  return (void *) dest;
}