summaryrefslogtreecommitdiff
path: root/src/common/strlib.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-02-01 19:19:26 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-02-01 19:19:26 +0000
commite38f00cc342543973a5a1faaa2db067f63dcb9e4 (patch)
treebeb73be04d5d40fa20e453de040679bd65468e97 /src/common/strlib.c
parent293439505d1fef24ca1596ee034d1897dc30ae0b (diff)
downloadhercules-e38f00cc342543973a5a1faaa2db067f63dcb9e4.tar.gz
hercules-e38f00cc342543973a5a1faaa2db067f63dcb9e4.tar.bz2
hercules-e38f00cc342543973a5a1faaa2db067f63dcb9e4.tar.xz
hercules-e38f00cc342543973a5a1faaa2db067f63dcb9e4.zip
Added string function strnlen
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9761 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/strlib.c')
-rw-r--r--src/common/strlib.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/common/strlib.c b/src/common/strlib.c
index 60ea266db..440a07742 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -192,3 +192,13 @@ char *_strtok_r(char *s1, const char *s2, char **lasts)
return ret;
}
#endif
+
+#if !defined(WIN32) || (defined(_MSC_VER) && _MSC_VER < 1400)
+/* Find the length of STRING, but scan at most MAXLEN characters.
+ If no '\0' terminator is found in that many characters, return MAXLEN. */
+size_t strnlen (const char* string, size_t maxlen)
+{
+ const char* end = memchr (string, '\0', maxlen);
+ return end ? (size_t) (end - string) : maxlen;
+}
+#endif