Skip to content

Commit bc5b3f8

Browse files
committed
stm: Add memcmp() implementation.
1 parent 1eacefe commit bc5b3f8

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

stm/string0.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ void *memset(void *s, int c, size_t n) {
3434
return s;
3535
}
3636

37+
int memcmp(const char *s1, const char *s2, size_t n) {
38+
while (n--) {
39+
char c1 = *s1++;
40+
char c2 = *s2++;
41+
if (c1 < c2) return -1;
42+
else if (c1 > c2) return 1;
43+
}
44+
return 0;
45+
}
46+
3747
size_t strlen(const char *str) {
3848
int len = 0;
3949
for (const char *s = str; *s; s++) {

0 commit comments

Comments
 (0)