Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(563)

Unified Diff: libiberty/strnlen.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « libiberty/simple-object-xcoff.c ('k') | libiberty/testsuite/demangle-expected » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libiberty/strnlen.c
diff --git a/libiberty/strnlen.c b/libiberty/strnlen.c
new file mode 100644
index 0000000000000000000000000000000000000000..4934973adcac15dce91f907915432b7e3b56fe9d
--- /dev/null
+++ b/libiberty/strnlen.c
@@ -0,0 +1,30 @@
+/* Portable version of strnlen.
+ This function is in the public domain. */
+
+/*
+
+@deftypefn Supplemental size_t strnlen (const char *@var{s}, size_t @var{maxlen})
+
+Returns the length of @var{s}, as with @code{strlen}, but never looks
+past the first @var{maxlen} characters in the string. If there is no
+'\0' character in the first @var{maxlen} characters, returns
+@var{maxlen}.
+
+@end deftypefn
+
+*/
+
+#include "config.h"
+
+#include <stddef.h>
+
+size_t
+strnlen (const char *s, size_t maxlen)
+{
+ size_t i;
+
+ for (i = 0; i < maxlen; ++i)
+ if (s[i] == '\0')
+ break;
+ return i;
+}
« no previous file with comments | « libiberty/simple-object-xcoff.c ('k') | libiberty/testsuite/demangle-expected » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698