[PATCH 1/9] PBL: Add strnlen, needed for printf support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



vsprintf needs strnlen, so in oder to add console support to
the PBL we need a strnlen implementation.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 pbl/string.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/pbl/string.c b/pbl/string.c
index b773f5c..927c92d 100644
--- a/pbl/string.c
+++ b/pbl/string.c
@@ -119,3 +119,17 @@ void *memset(void *s, int c, size_t count)
 		*xs++ = c;
 	return s;
 }
+
+/**
+ * strnlen - Find the length of a length-limited string
+ * @s: The string to be sized
+ * @count: The maximum number of bytes to search
+ */
+size_t strnlen(const char * s, size_t count)
+{
+	const char *sc;
+
+	for (sc = s; count-- && *sc != '\0'; ++sc)
+		/* nothing */;
+	return sc - s;
+}
-- 
2.1.3


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux