.
[gnulib.git] / lib / memcpy.c
1 /* memcpy.c -- copy memory.
2    Copy LENGTH bytes from SOURCE to DEST.  Does not null-terminate.
3    The source and destination regions may not overlap.
4    In the public domain.
5    By Jim Meyering.  */
6
7 /* FIXME: remove this before release.  */
8 #include <assert.h>
9 #ifndef ABS
10 # define ABS(x) ((x) < 0 ? (-(x)) : (x))
11 #endif
12
13 void
14 memcpy (dest, source, length)
15      char *dest;
16      const char *source;
17      unsigned length;
18 {
19   assert (length >= 0);
20   /* Make sure they don't overlap.  */
21   assert (ABS (dest - source) >= length);
22
23   for (; length; --length)
24     *dest++ = *source++;
25 }