Commit 1e6f0ac4 by Carlos Martín Nieto

utils: don't reimplement strnlen

The standard library provides a very nice strnlen function, which knows
to use SSE, let's not reimplement it ourselves.
parent a6563619
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#ifndef INCLUDE_util_h__ #ifndef INCLUDE_util_h__
#define INCLUDE_util_h__ #define INCLUDE_util_h__
#include "posix.h"
#include "common.h" #include "common.h"
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
...@@ -50,8 +51,7 @@ GIT_INLINE(char *) git__strndup(const char *str, size_t n) ...@@ -50,8 +51,7 @@ GIT_INLINE(char *) git__strndup(const char *str, size_t n)
size_t length = 0; size_t length = 0;
char *ptr; char *ptr;
while (length < n && str[length]) length = p_strnlen(str, n);
++length;
ptr = (char*)git__malloc(length + 1); ptr = (char*)git__malloc(length + 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment