From 3b68e7de64c9161f033b7c5479b00b6800263015 Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Sun, 17 May 2020 19:29:36 +0200 Subject: [PATCH] mescc: Mes C Library: Prepare for M2-Planet: memcpy. * lib/string/memcpy.c: Rewrite C-constructs not supported by M2-Planet. --- lib/string/memcpy.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/string/memcpy.c b/lib/string/memcpy.c index 289a4063..3295d3f7 100644 --- a/lib/string/memcpy.c +++ b/lib/string/memcpy.c @@ -21,12 +21,24 @@ #include #include +char * +_memcpy (char *dest, char const *src, size_t n) +{ + char *p = dest; + + while (n != 0) + { + n = n - 1; + dest[0] = src[0]; + dest = dest + 1; + src = src + 1; + } + + return p; +} + void * memcpy (void *dest, void const *src, size_t n) { - char *p = dest; - char const *q = src; - while (n--) - *p++ = *q++; - return dest; + return _memcpy (dest, src, n); }