Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src/util/pactree.c
diff options
context:
space:
mode:
authorWill Miles <wmiles@sgl.com>2015-02-27 14:43:23 -0500
committerAllan McRae <allan@archlinux.org>2015-03-03 16:54:17 +1000
commitbb94729c098f21ae850044a9201c1d5b92baea1f (patch)
tree2f0ffe7f158bf4a8c458ebc78cc3cf35f7f63d4d /src/util/pactree.c
parent8f92fe47a7c4d999271bc28ffbbeeea50d686813 (diff)
util: Use util-common for strndup in pacsort and pactree
This small refactor reduces the number of replications of the local imeplementation of strndup. Signed-off-by: Will Miles <wmiles@sgl.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'src/util/pactree.c')
-rw-r--r--src/util/pactree.c24
1 files changed, 2 insertions, 22 deletions
diff --git a/src/util/pactree.c b/src/util/pactree.c
index 67f456fe..11ad7cae 100644
--- a/src/util/pactree.c
+++ b/src/util/pactree.c
@@ -29,6 +29,8 @@
#include <langinfo.h>
#endif
+#include "util-common.h"
+
#define LINE_MAX 512
typedef struct tdepth {
@@ -121,28 +123,6 @@ int searchsyncs = 0;
const char *dbpath = DBPATH;
const char *configfile = CONFFILE;
-#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
-
static size_t strtrim(char *str)
{
char *end, *pch = str;