From f6b71172b5ad02df522f66ef95ec2b0eb1239a29 Mon Sep 17 00:00:00 2001 From: flyingcys <294102238@qq.com> Date: Thu, 2 Nov 2017 11:12:55 +0800 Subject: [PATCH] fix rt_memcpy buf in RT_USING_TINY_SIZE enable --- src/kservice.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/kservice.c b/src/kservice.c index 4afea50bca..7b51f60ca3 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -220,11 +220,20 @@ void *rt_memcpy(void *dst, const void *src, rt_ubase_t count) { #ifdef RT_USING_TINY_SIZE char *tmp = (char *)dst, *s = (char *)src; + rt_ubase_t len; + + if(tmp <= s || tmp > (s + count)) + { + while (count--) + *tmp ++ = *s ++; + } + else + { + for(len = count; len > 0; len --) + tmp[len -1] = s[len - 1]; + } - while (count--) - *tmp++ = *s++; - - return dst; + return dst; #else #define UNALIGNED(X, Y) \