index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | lib/libalpm/util.c | 22 |
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 2eee5e4a..81d950e8 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -937,4 +937,26 @@ long _alpm_parsedate(const char *line) return(atol(line)); } +#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: */ |