[OpenBSD]

Manual Page Search Parameters

LSEARCH(3) Library Functions Manual LSEARCH(3)

NAME

lsearch, lfindlinear searching routines

SYNOPSIS

#include <search.h>
void *
lsearch(const void *key, void *base, size_t *nelp, size_t width, int (*compar)(const void *, const void *));
void *
lfind(const void *key, const void *base, size_t *nelp, size_t width, int (*compar)(const void *, const void *));

DESCRIPTION

The functions lsearch() and lfind() provide basic linear searching functionality.
base is the pointer to the beginning of an array. The argument nelp is the current number of elements in the array, where each element is width bytes long. The compar function is a comparison routine which is used to compare two elements. It takes two arguments which point to the key object and to an array member, in that order, and must return an integer less than, equivalent to, or greater than zero if the key object is considered, respectively, to be less than, equal to, or greater than the array member.
The lsearch() and lfind() functions return a pointer into the array referenced by base where key is located. If key does not exist, lfind() will return a null pointer and lsearch() will add it to the array. When an element is added to the array by lsearch(), the location referenced by the argument nelp is incremented by one.

SEE ALSO

bsearch(3), dbopen(3)

STANDARDS

The lsearch() and lfind() functions conform to the X/Open System Interfaces option of the IEEE Std 1003.1-2008 (“POSIX.1”) specification.
November 30, 2015 OpenBSD-current