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