diff options
-rw-r--r-- | lib/string.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/string.c b/lib/string.c index b375b81..2c4f0ec 100644 --- a/lib/string.c +++ b/lib/string.c @@ -467,6 +467,9 @@ void * memcpy(void *dest, const void *src, size_t count) unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src; char *d8, *s8; + if (src == dest) + return dest; + /* while all data is aligned (common case), copy a word at a time */ if ( (((ulong)dest | (ulong)src) & (sizeof(*dl) - 1)) == 0) { while (count >= sizeof(*dl)) { @@ -497,6 +500,9 @@ void * memmove(void * dest,const void *src,size_t count) { char *tmp, *s; + if (src == dest) + return dest; + if (dest <= src) { tmp = (char *) dest; s = (char *) src; |