revert previous, my include files were out of day.

This commit is contained in:
christos 2005-07-16 17:32:09 +00:00
parent 76e7e3ea51
commit fce61e5249
1 changed files with 10 additions and 10 deletions

View File

@ -35,7 +35,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)lsearch.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)lsearch.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: lsearch.c,v 1.3 2005/07/16 17:15:46 christos Exp $"); __RCSID("$NetBSD: lsearch.c,v 1.4 2005/07/16 17:32:09 christos Exp $");
#endif #endif
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
@ -47,13 +47,13 @@ __RCSID("$NetBSD: lsearch.c,v 1.3 2005/07/16 17:15:46 christos Exp $");
#include <search.h> #include <search.h>
typedef int (*cmp_fn_t) __P((const void *, const void *)); typedef int (*cmp_fn_t) __P((const void *, const void *));
static void *linear_base __P((const void *, const void *, size_t *, size_t, static void *linear_base __P((const void *, void *, size_t *, size_t,
cmp_fn_t, int)); cmp_fn_t, int));
void * void *
lsearch(key, base, nelp, width, compar) lsearch(key, base, nelp, width, compar)
const void *key; const void *key;
const void *base; void *base;
size_t *nelp, width; size_t *nelp, width;
cmp_fn_t compar; cmp_fn_t compar;
{ {
@ -82,21 +82,21 @@ lfind(key, base, nelp, width, compar)
static void * static void *
linear_base(key, base, nelp, width, compar, add_flag) linear_base(key, base, nelp, width, compar, add_flag)
const void *key; const void *key;
const void *base; void *base;
size_t *nelp, width; size_t *nelp, width;
cmp_fn_t compar; cmp_fn_t compar;
int add_flag; int add_flag;
{ {
const char *element, *end; char *element, *end;
_DIAGASSERT(key != NULL); _DIAGASSERT(key != NULL);
_DIAGASSERT(base != NULL); _DIAGASSERT(base != NULL);
_DIAGASSERT(compar != NULL); _DIAGASSERT(compar != NULL);
end = (const char *)base + *nelp * width; end = (char *)base + *nelp * width;
for (element = (const char *)base; element < end; element += width) for (element = (char *)base; element < end; element += width)
if (!compar(element, key)) /* key found */ if (!compar(element, key)) /* key found */
return __UNCONST(element); return element;
if (!add_flag) /* key not found */ if (!add_flag) /* key not found */
return(NULL); return(NULL);
@ -111,6 +111,6 @@ linear_base(key, base, nelp, width, compar, add_flag)
* manual. * manual.
*/ */
++*nelp; ++*nelp;
memcpy(__UNCONST(end), key, width); memcpy(end, key, width);
return __UNCONST(end); return end;
} }