diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-08-08 05:30:19 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-08-08 05:30:19 +0000 |
commit | b469c3481676e22af91d4a4b2049548c9cfc27c9 (patch) | |
tree | c0443ca848f3b9b5f303d1a00c77adbaad6e55b2 /libc | |
parent | dbd8d5979426a1b555bca65359e30d1de038f24b (diff) |
Cleanup warnings and fix prototypes
-Erik
Diffstat (limited to 'libc')
-rw-r--r-- | libc/misc/lsearch/lsearch.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/libc/misc/lsearch/lsearch.c b/libc/misc/lsearch/lsearch.c index ace739211..8b10fd874 100644 --- a/libc/misc/lsearch/lsearch.c +++ b/libc/misc/lsearch/lsearch.c @@ -10,34 +10,29 @@ #include <string.h> #include <stdio.h> +#include <search.h> -char *lfind(key, base, num, size, cmp) -register char *key, *base; -unsigned int *num; -register unsigned int size; -register int (*cmp) (); +void *lfind(const void *key, const void *base, size_t *nmemb, + size_t size, int (*compar)(const void *, const void *)) { - register int n = *num; + register int n = *nmemb; while (n--) { - if ((*cmp) (base, key) == 0) - return (base); + if ((*compar) (base, key) == 0) + return ((void*)base); base += size; } return (NULL); } -char *lsearch(key, base, num, size, cmp) -char *key, *base; -register unsigned int *num; -register unsigned int size; -int (*cmp) (); +void *lsearch(const void *key, void *base, size_t *nmemb, + size_t size, int (*compar)(const void *, const void *)) { register char *p; - if ((p = lfind(key, base, num, size, cmp)) == NULL) { - p = memcpy((base + (size * (*num))), key, size); - ++(*num); + if ((p = lfind(key, base, nmemb, size, compar)) == NULL) { + p = memcpy((base + (size * (*nmemb))), key, size); + ++(*nmemb); } return (p); } |