aboutsummaryrefslogtreecommitdiff
path: root/src/arm/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/arm/common')
-rw-r--r--src/arm/common/strings.c36
-rw-r--r--src/arm/common/strings.h6
2 files changed, 31 insertions, 11 deletions
diff --git a/src/arm/common/strings.c b/src/arm/common/strings.c
index 368d7dc..0c7a73b 100644
--- a/src/arm/common/strings.c
+++ b/src/arm/common/strings.c
@@ -69,15 +69,6 @@ void uint32_to_hexstringt(uint32_t number, char buf[9])
trim_0s(buf);
}
-size_t strlen(char string[])
-{
- size_t len;
-
- for (len = 0; string[len]; len++);
-
- return len;
-}
-
void memcpy(void *dst, void *src, size_t nbytes)
{
size_t iter;
@@ -117,3 +108,30 @@ char *strcat(char *dst, const char *src)
return dst;
}
+
+int strcmp(char const *str1, char const *str2)
+{
+ while (1)
+ {
+ int c1 = (unsigned char) *str1, c2 = (unsigned char) *str2;
+
+ if (!c1 && !c2)
+ return 0;
+
+ if (c1 != c2)
+ return c1 - c2;
+
+ str1++; str2++;
+ }
+}
+
+size_t strlen(char const *str1)
+{
+ size_t len = 0;
+
+ while (str1[len])
+ len++;
+
+ return len;
+}
+
diff --git a/src/arm/common/strings.h b/src/arm/common/strings.h
index aff0533..67c1ab7 100644
--- a/src/arm/common/strings.h
+++ b/src/arm/common/strings.h
@@ -22,12 +22,14 @@ void uint32_to_decstringt(uint32_t number, char buf[11]);
void uint32_to_hexstringt(uint32_t number, char buf[9]);
-size_t strlen(char string[]);
-
void memcpy(void *dst, void *src, size_t nbytes);
void *memset(void *s, int c, size_t n);
char *strcat(char *dst, const char *src);
+int strcmp(char const *str1, char const *str2);
+
+size_t strlen(char const *str1);
+
#endif // STRINGS_H