libc: Add memchr implementation
Needed by CoAP implementation in net/ip/er-coap
Change-Id: I724bc7569a29c35f386bbc301d883a000882de78
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
diff --git a/lib/libc/minimal/source/string/string.c b/lib/libc/minimal/source/string/string.c
index cdd7137..564d79d 100644
--- a/lib/libc/minimal/source/string/string.c
+++ b/lib/libc/minimal/source/string/string.c
@@ -306,3 +306,26 @@
return buf;
}
+
+/**
+ *
+ * @brief Scan byte in memory
+ *
+ * @return pointer to start of found byte
+ */
+
+void *memchr(const void *s, unsigned char c, size_t n)
+{
+ if (n != 0) {
+ const unsigned char *p = s;
+
+ do {
+ if (*p++ == c) {
+ return ((void *)(p - 1));
+ }
+
+ } while (--n != 0);
+ }
+
+ return NULL;
+}