NAME
llsseeaarrcchh, llffiinndd - linear search and append
LLIIBBRRAARRYYStandard C Library (libc, -lc)
SYNOPSIS
##iinncclluuddee <
void * llsseeaarrcchh(const void *key, void *base, sizet *nelp, sizet width, int (*compar)(const void *, const void *)); void * llffiinndd(const void *key, const void *base, sizet *nelp, sizet width, int (*compar)(const void *, const void *));> DESCRIPTION
The llsseeaarrcchh() and llffiinndd() functions walk linearly through an array andcompare each element with the one to be sought using a supplied compari-
son function. The key argument points to an element that matches the one that is searched. The array's address in memory is denoted by the base argument. The width of one element (i.e., the size as returned by ssiizzeeooff()) is passed as the width argument. The number of valid elements contained in the array (not the number of elements the array has space reserved for) is given in the integer pointed to by nelp. The compar argument points to a function which compares its two arguments and returns zero if theyare matching, and non-zero otherwise.
If no matching element was found in the array, llsseeaarrcchh() copies key into the position after the last element and increments the integer pointed to by nelp.RETURN VALUES
The llsseeaarrcchh() and llffiinndd() functions return a pointer to the first element found. If no element was found, llsseeaarrcchh() returns a pointer to the newly added element, whereas llffiinndd() returns NULL. Both functions return NULL if an error occurs.SEE ALSO
bsearch(3), hsearch(3), tsearch(3) HISTORY The llsseeaarrcchh() and llffiinndd() functions appeared in 4.2BSD. In FreeBSD 5.0,they reappeared conforming to IEEE Std 1003.1-2001 (``POSIX.1'').
STANDARDSThe llsseeaarrcchh() and llffiinndd() functions conform to IEEE Std 1003.1-2001
(``POSIX.1''). BSD October 11, 2002 BSD