Page MenuHomeFreeBSD

D58876.id184148.diff
No OneTemporary

D58876.id184148.diff

diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc
--- a/lib/libc/stdlib/Makefile.inc
+++ b/lib/libc/stdlib/Makefile.inc
@@ -109,6 +109,7 @@
abs.3 llabs.3 \
abs.3 imaxabs.3
MLINKS+=atol.3 atoll.3
+MLINKS+=bsearch.3 bsearch_b.3
MLINKS+=div.3 ldiv.3 \
div.3 lldiv.3 \
div.3 imaxdiv.3
diff --git a/lib/libc/stdlib/bsearch.3 b/lib/libc/stdlib/bsearch.3
--- a/lib/libc/stdlib/bsearch.3
+++ b/lib/libc/stdlib/bsearch.3
@@ -29,11 +29,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd June 21, 2026
+.Dd August 15, 2026
.Dt BSEARCH 3
.Os
.Sh NAME
-.Nm bsearch
+.Nm bsearch ,
+.Nm bsearch_b
.Nd binary search of a sorted table
.Sh LIBRARY
.Lb libc
@@ -41,6 +42,8 @@
.In stdlib.h
.Ft "QVoid *"
.Fn bsearch "const void *key" "QVoid *base" "size_t nmemb" "size_t size" "int (*compar) (const void *, const void *)"
+.Ft "QVoid *"
+.Fn bsearch_b "const void *key" "QVoid *base" "size_t nmemb" "size_t size" "int (^compar) (const void *, const void *)"
.Sh DESCRIPTION
The
.Fn bsearch
@@ -74,10 +77,20 @@
.Xr qsort 3
for a comparison function that is also compatible with
.Fn bsearch .
+.Pp
+The
+.Fn bsearch_b
+function behaves identically to
+.Fn bsearch ,
+except the callback
+.Fa compar
+takes a block pointer instead of a function pointer.
.Sh RETURN VALUES
The
.Fn bsearch
-function returns a pointer to a matching member of the array, or a null
+and
+.Fn bsearch_b
+functions return a pointer to a matching member of the array, or a null
pointer if no match is found.
If two members compare as equal, which member is matched is unspecified.
.Sh EXAMPLES

File Metadata

Mime Type
text/plain
Expires
Fri, Aug 21, 4:21 AM (20 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37020813
Default Alt Text
D58876.id184148.diff (1 KB)

Event Timeline