summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorrsc <rsc>2006-07-16 01:47:40 +0000
committerrsc <rsc>2006-07-16 01:47:40 +0000
commit856e1fc1ad22a24bd71c706bc06ba868e044ddc8 (patch)
tree203bf24aa99e2f50d4bca375231d3fb46332ba29 /string.c
parent65bd8e139a8368e987455a10ec59dd7b079b3af1 (diff)
downloadxv6-labs-856e1fc1ad22a24bd71c706bc06ba868e044ddc8.tar.gz
xv6-labs-856e1fc1ad22a24bd71c706bc06ba868e044ddc8.tar.bz2
xv6-labs-856e1fc1ad22a24bd71c706bc06ba868e044ddc8.zip
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.
Diffstat (limited to 'string.c')
-rw-r--r--string.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/string.c b/string.c
index c88e7de..07082e5 100644
--- a/string.c
+++ b/string.c
@@ -2,18 +2,6 @@
#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)
{
char *d = (char *) dst;
@@ -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;
+}
+