BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / commit / 77a8df88b03707e14f840df6b0daeb9fa081f613 / lib

// Related

Nucleus

Barry FS Object wrapper functions 77a8df8 (3 years, 3 months ago)
diff --git a/lib/string.c b/lib/string.c
index 5b9506e..945ffa5 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -39,7 +39,7 @@ strncpy(char *dest, const char *src, size_t n)
 	return ret;
 }
 
-/* Find length of string */
+/* Find length of a string */
 size_t
 strlen(const char *str)
 {
@@ -49,3 +49,15 @@ strlen(const char *str)
 	for (i = 0; str[i]; i++);
 	return i;
 }
+
+/* Find length of a limited string */
+size_t
+strnlen(const char *str, size_t n)
+{
+	if (!str)
+		return 0;
+	size_t i;
+	for (i = 0; str[i] && i <= n; i++);
+	return i;
+}
+