8 #define NULL ((void *) 0)
11 static int strcmp(const char *s1
, const char *s2
)
13 while ((*s1
== *s2
) && *s1
!= '\0') {
21 static int strncmp(const char *s1
, const char *s2
, int n
)
23 while ((--n
) && (*s1
== *s2
) && *s1
!= '\0') {
32 static char *strcpy(char *dest
, const char *src
)
36 while ((*dest
++ = *src
++) != '\0')
42 static char *strcat(char *dest
, const char *src
)
48 while ((*dest
++ = *src
++) != '\0')
54 static size_t strlen(const char *s
)
58 for (sc
= s
; *sc
; ++sc
)
64 static char *strchr (const char *s
, int c
)
75 static char *strrchr (char *s
, int c
)
77 char *end
= s
+ strlen(s
) - 1;
79 while (*end
!= c
&& end
>= s
)
86 static char *strdup(const char *str
)
88 char *s
= malloc(strlen(str
) + 1);
95 static void *memset(void *s
, int c
, size_t count
)
104 static void *memset_word(void *s
, unsigned short word
, size_t count
)
106 unsigned short *xs
= (unsigned short *)s
;
113 static void *memcpy(void *dest
, const void *src
, size_t count
)
124 static void *memmove(void *dest
, const void *src
, size_t count
)
146 static int memcmp(const void *cs
, const void *ct
, size_t count
)
148 const unsigned char *su1
, *su2
;
151 for (su1
= cs
, su2
= ct
; 0 < count
; ++su1
, ++su2
, count
--)
152 if ((res
= *su1
- *su2
) != 0)
158 #endif /* _STRING_H */