]> git.saurik.com Git - apple/libc.git/blob - stdlib/FreeBSD/bsearch.3.patch
Libc-763.13.tar.gz
[apple/libc.git] / stdlib / FreeBSD / bsearch.3.patch
1 --- bsearch.3.bsdnew 2009-11-13 14:11:47.000000000 -0800
2 +++ bsearch.3 2009-11-13 14:11:48.000000000 -0800
3 @@ -32,30 +32,37 @@
4 .\" @(#)bsearch.3 8.3 (Berkeley) 4/19/94
5 .\" $FreeBSD: src/lib/libc/stdlib/bsearch.3,v 1.9 2007/01/09 00:28:09 imp Exp $
6 .\"
7 -.Dd April 19, 1994
8 +.Dd May 20, 2008
9 .Dt BSEARCH 3
10 .Os
11 .Sh NAME
12 +#ifdef UNIFDEF_BLOCKS
13 +.Nm bsearch ,
14 +.Nm bsearch_b
15 +#else
16 .Nm bsearch
17 +#endif
18 .Nd binary search of a sorted table
19 -.Sh LIBRARY
20 -.Lb libc
21 .Sh SYNOPSIS
22 .In stdlib.h
23 .Ft void *
24 -.Fn bsearch "const void *key" "const void *base" "size_t nmemb" "size_t size" "int (*compar) (const void *, const void *)"
25 +.Fn bsearch "const void *key" "const void *base" "size_t nel" "size_t width" "int (*compar) (const void *, const void *)"
26 +#ifdef UNIFDEF_BLOCKS
27 +.Ft void *
28 +.Fn bsearch_b "const void *key" "const void *base" "size_t nel" "size_t width" "int (^compar) (const void *, const void *)"
29 +#endif
30 .Sh DESCRIPTION
31 The
32 .Fn bsearch
33 function searches an array of
34 -.Fa nmemb
35 +.Fa nel
36 objects, the initial member of which is
37 pointed to by
38 .Fa base ,
39 for a member that matches the object pointed to by
40 .Fa key .
41 -The size of each member of the array is specified by
42 -.Fa size .
43 +The size (in bytes) of each member of the array is specified by
44 +.Fa width .
45 .Pp
46 The contents of the array should be in ascending sorted order according
47 to the comparison function referenced by
48 @@ -66,15 +73,33 @@ routine
49 is expected to have
50 two arguments which point to the
51 .Fa key
52 -object and to an array member, in that order, and should return an integer
53 +object and to an array member, in that order.
54 +It should return an integer which is
55 less than, equal to, or greater than zero if the
56 .Fa key
57 object is found, respectively, to be less than, to match, or be
58 greater than the array member.
59 +#ifdef UNIFDEF_BLOCKS
60 +.Pp
61 +The
62 +.Fn bsearch_b
63 +function is like
64 +.Fn bsearch
65 +except the callback
66 +.Fa compar
67 +is a block pointer instead of a function pointer.
68 +#endif
69 .Sh RETURN VALUES
70 The
71 .Fn bsearch
72 -function returns a pointer to a matching member of the array, or a null
73 +#ifdef UNIFDEF_BLOCKS
74 +and
75 +.Fn bsearch_b
76 +functions
77 +#else
78 +function
79 +#endif
80 +returns a pointer to a matching member of the array, or a null
81 pointer if no match is found.
82 If two members compare as equal, which member is matched is unspecified.
83 .Sh SEE ALSO