CVSROOT:        /cvs
Module name:    src
Changes by:     chel...@cvs.openbsd.org 2021/12/08 15:06:28

Modified files:
        lib/libc/stdlib: lsearch.c 
        lib/libc/hidden: search.h 

Log message:
lsearch(3): reimplement using lfind(3)

lsearch(3) is really just lfind(3) with an additional branch to append
the key if lfind(3) fails.  If we get rid of the underlying
linear_base() function and move the search portion into lfind(3) and
the key-copying portion into lsearch(3) we get smaller and simpler
code.

Misc. notes:

- We do not need to keep the historical comment about errno.  lsearch(3)
is pure computation and does not set errno.  That's really all you
need to know.  The specification reserves no errors, either.

- We are using lfind(3) internally now, so it switches from
PROTO_DEPRECATED to PROTO_NORMAL in hidden/search.h and needs
DEF_WEAK in stdlib/lsearch.c.

With advice from guenther@ on symbol housekeeping in libc.

Thread: https://marc.info/?l=openbsd-tech&m=163885187632449&w=2

ok millert@

Reply via email to