arc: clone: Simplify CLONE_THREAD detection
[uclibc-ng.git] / libc / misc / search / _lsearch.c
blob0cf496e265132272c3a1476c52b9f8c16c7da1f5
1 /*
2 * This file lifted in toto from 'Dlibs' on the atari ST (RdeBath)
5 * Dale Schumacher 399 Beacon Ave.
6 * (alias: Dalnefre') St. Paul, MN 55104
7 * dal@syntel.UUCP United States of America
8 * "It's not reality that's important, but how you perceive things."
9 */
11 #include <string.h>
12 #include <stdio.h>
13 #include <search.h>
16 #ifdef L_lfind
18 void *lfind(const void *key, const void *base, size_t *nmemb,
19 size_t size, int (*compar)(const void *, const void *))
21 register int n = *nmemb;
23 while (n--) {
24 if ((*compar) (key, base) == 0)
25 return ((void*)base);
26 base += size;
28 return (NULL);
30 libc_hidden_def(lfind)
32 #endif
34 #ifdef L_lsearch
37 void *lsearch(const void *key, void *base, size_t *nmemb,
38 size_t size, int (*compar)(const void *, const void *))
40 register char *p;
42 if ((p = lfind(key, base, nmemb, size, compar)) == NULL) {
43 p = memcpy((base + (size * (*nmemb))), key, size);
44 ++(*nmemb);
46 return (p);
49 #endif