index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dave Reisner <dreisner@archlinux.org> | 2011-09-18 16:22:38 -0400 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-09-18 16:58:21 -0500 |
commit | 83ee9708b1c0ed3c262e0148ea8cdc880f177d0d (patch) | |
tree | 8b605f9be56f0361b81d2876813843cc6d950843 /src/util/pactree.c | |
parent | 07e89c1e5db2769c1128f5d99fead151a4afc751 (diff) |
-rw-r--r-- | src/util/pactree.c | 22 |
diff --git a/src/util/pactree.c b/src/util/pactree.c index 11ca4b9e..09fe1011 100644 --- a/src/util/pactree.c +++ b/src/util/pactree.c @@ -91,6 +91,28 @@ int unique = 0; int searchsyncs = 0; const char *dbpath = DBPATH; +#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 char *strtrim(char *str) { char *pch = str; |