]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Don't use unportable strnlen function
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 5 Apr 2010 09:15:54 +0000 (11:15 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 5 Apr 2010 09:15:54 +0000 (11:15 +0200)
util.c

diff --git a/util.c b/util.c
index ce95d0aaec3133bd79b6570b4beed70eea47f786..56fec52c69be3b0e5a002708315ab411165c4535 100644 (file)
--- a/util.c
+++ b/util.c
@@ -382,8 +382,10 @@ char *x_strndup(const char *s, size_t n)
 
        if (!s)
                return NULL;
-       m = strnlen(s, n);
-       m = n < m ? n : m;
+       m = 0;
+       while (m < n && s[m]) {
+               m++;
+       }
        ret = malloc(m + 1);
        if (ret) {
                memcpy(ret, s, m);