1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-21 11:16:16 +02:00

Add assertions.

This commit is contained in:
Jim Meyering
1996-10-04 13:42:20 +00:00
parent fdd16fdb62
commit 3400ffe3f2

View File

@@ -2,6 +2,15 @@
if the source overlaps with the destination.
Return DESTADDR. */
#include <assert.h>
/* FIXME: uncomment the following for releases. */
#define NDEBUG 1
#ifndef ABS
# define ABS(x) ((x) < 0 ? (-(x)) : (x))
#endif
char *
memcpy (destaddr, srcaddr, len)
char *destaddr;
@@ -10,6 +19,10 @@ memcpy (destaddr, srcaddr, len)
{
char *dest = destaddr;
assert (len >= 0);
/* Make sure they don't overlap. */
assert (ABS (destaddr - srcaddr) >= len);
while (len-- > 0)
*destaddr++ = *srcaddr++;
return dest;