comparison lib/memcpy.c @ 280:2b8b9312ed33

GNU text utilities
author Jim Meyering <jim@meyering.net>
date Tue, 21 Mar 1995 03:48:38 +0000
parents
children 1da40035bfa2
comparison
equal deleted inserted replaced
279:e512303d74b8 280:2b8b9312ed33
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 }