[Sound-open-firmware] [PATCH] lib: string: Add rstrcmp() string compare.
Liam Girdwood
liam.r.girdwood at linux.intel.com
Thu Apr 12 09:57:42 CEST 2018
Add strcmp() equivalent.
Signed-off-by: Liam Girdwood <liam.r.girdwood at linux.intel.com>
---
src/include/sof/alloc.h | 1 +
src/lib/lib.c | 17 +++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/src/include/sof/alloc.h b/src/include/sof/alloc.h
index d87795d2..d5fc1c2d 100644
--- a/src/include/sof/alloc.h
+++ b/src/include/sof/alloc.h
@@ -113,6 +113,7 @@ void *rballoc(int zone, uint32_t flags, size_t bytes);
void bzero(void *s, size_t n);
void *memset(void *s, int c, size_t n);
int rstrlen(const char *s);
+int rstrcmp(const char *s1, const char *s2);
/* Heap save/restore contents and context for PM D0/D3 events */
uint32_t mm_pm_context_size(void);
diff --git a/src/lib/lib.c b/src/lib/lib.c
index 5aa194c8..79198fd9 100644
--- a/src/lib/lib.c
+++ b/src/lib/lib.c
@@ -106,3 +106,20 @@ int rstrlen(const char *s)
while(*p++ != 0);
return (p - s) - 1;
}
+
+/* generic string compare */
+int rstrcmp(const char *s1, const char *s2)
+{
+ while (*s1 != 0 && *s2 != 0) {
+ if (*s1 < *s2)
+ return -1;
+ if (*s1 > *s2)
+ return 1;
+ s1++;
+ s2++;
+ }
+
+ /* match */
+ return 0;
+}
+
--
2.14.1
More information about the Sound-open-firmware
mailing list