From 856e1fc1ad22a24bd71c706bc06ba868e044ddc8 Mon Sep 17 00:00:00 2001 From: rsc Date: Sun, 16 Jul 2006 01:47:40 +0000 Subject: Attempt to clean up newproc somewhat. Also remove all calls to memcpy in favor of memmove, which has defined semantics when the ranges overlap. The fact that memcpy was working in console.c to scroll the screen is not guaranteed by all implementations. --- string.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'string.c') diff --git a/string.c b/string.c index c88e7de..07082e5 100644 --- a/string.c +++ b/string.c @@ -1,18 +1,6 @@ #include "types.h" #include "defs.h" -void * -memcpy(void *dst, void *src, unsigned n) -{ - char *d = (char *) dst; - char *s = (char *) src; - - while(n-- > 0) - *d++ = *s++; - - return dst; -} - void * memset(void *dst, int c, unsigned n) { @@ -69,3 +57,21 @@ strncmp(const char *p, const char *q, unsigned n) else return (int) ((unsigned char) *p - (unsigned char) *q); } + +// Memcpy is deprecated and should NOT be called. +// Use memmove instead, which has defined semantics +// when the two memory ranges overlap. +// Memcpy is here only because gcc compiles some +// structure assignments into calls to memcpy. +void * +memcpy(void *dst, void *src, unsigned n) +{ + char *d = (char *) dst; + char *s = (char *) src; + + while(n-- > 0) + *d++ = *s++; + + return dst; +} + -- cgit v1.2.3