[pacman-dev] [PATCH] remove the duplicate strnlen and strndup

Simon Gomizelj simongmzlj at gmail.com
Thu Mar 7 01:24:15 EST 2013


Signed-off-by: Simon Gomizelj <simongmzlj at gmail.com>
---
 src/pacman/util.c | 22 ----------------------
 1 file changed, 22 deletions(-)

diff --git a/src/pacman/util.c b/src/pacman/util.c
index 3270c74..cc0e548 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -1635,26 +1635,4 @@ int pm_vfprintf(FILE *stream, alpm_loglevel_t level, const char *format, va_list
 	return ret;
 }
 
-#ifndef HAVE_STRNDUP
-/* A quick and dirty implementation derived from glibc */
-static size_t strnlen(const char *s, size_t max)
-{
-    register const char *p;
-    for(p = s; *p && max--; ++p);
-    return (p - s);
-}
-
-char *strndup(const char *s, size_t n)
-{
-  size_t len = strnlen(s, n);
-  char *new = (char *) malloc(len + 1);
-
-  if(new == NULL)
-    return NULL;
-
-  new[len] = '\0';
-  return (char *)memcpy(new, s, len);
-}
-#endif
-
 /* vim: set ts=2 sw=2 noet: */
-- 
1.8.1.5



More information about the pacman-dev mailing list