stm: Add memcmp() implementation.

This commit is contained in:
Paul Sokolovsky 2014-01-23 01:51:02 +02:00
parent 1eacefe5bc
commit bc5b3f8c73
1 changed files with 10 additions and 0 deletions

View File

@ -34,6 +34,16 @@ void *memset(void *s, int c, size_t n) {
return s; return s;
} }
int memcmp(const char *s1, const char *s2, size_t n) {
while (n--) {
char c1 = *s1++;
char c2 = *s2++;
if (c1 < c2) return -1;
else if (c1 > c2) return 1;
}
return 0;
}
size_t strlen(const char *str) { size_t strlen(const char *str) {
int len = 0; int len = 0;
for (const char *s = str; *s; s++) { for (const char *s = str; *s; s++) {