2 .\" Copyright 1995 Jim Van Zandt <jrv@vanzandt.mv.com>
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" Corrected prototype and include, aeb, 990927
7 .TH lsearch 3 (date) "Linux man-pages (unreleased)"
9 lfind, lsearch \- linear search of an array
12 .RI ( libc ", " \-lc )
15 .B #include <search.h>
17 .BI "void *lfind(const void " key [. size "], \
18 const void " base [. size " * ." nmemb ],
19 .BI " size_t *" nmemb ", size_t " size ,
20 .BI " int(*" compar ")(const void [." size "], \
21 const void [." size ]));
22 .BI "void *lsearch(const void " key [. size "], \
23 void " base [. size " * ." nmemb ],
24 .BI " size_t *" nmemb ", size_t " size ,
25 .BI " int(*" compar ")(const void [." size "], \
26 const void [." size ]));
32 perform a linear search for
41 The comparison function referenced by
43 is expected to have two arguments which point to the
45 object and to an array member, in that order, and which
48 object matches the array member, and
53 does not find a matching element, then the
55 object is inserted at the end of the table, and
59 In particular, one should know that a matching element
60 exists, or that more room is available.
63 returns a pointer to a matching member of the array, or
64 NULL if no match is found.
67 a matching member of the array, or to the newly added member if no
70 For an explanation of the terms used in this section, see
78 Interface Attribute Value
82 T} Thread safety MT-Safe
90 POSIX.1-2001, SVr4, 4.3BSD.
93 The naming is unfortunate.