]> git.ozlabs.org Git - ccan/commit
asearch: Add context pointer to asearch comparison callback
authorDavid Gibson <david@gibson.dropbear.id.au>
Wed, 27 May 2015 14:17:35 +0000 (00:17 +1000)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 28 May 2015 03:45:17 +0000 (13:15 +0930)
commite7519047a8b495c8e4011168c7ee777db0d90dc9
treee6144b3566d8408700a0ee06e19d3151faab089a
parent8ad4e453eec3ab9e4e39bb7befcc7e62a5edd05f
asearch: Add context pointer to asearch comparison callback

asearch, like the standard library bsearch, takes a comparison callback.
Like bsearch() that callback doesn't include a user supplied context
pointer.  As well as being generally limiting, that makes the comparison
functions used by asearch gratuitously different from those used by the
asort module.

This patch alters this.  Note that this is an incompatible change to the
asearch interface.  I think this is worth it to correct the oversight, but
others might disagree.  At present the only user within ccan is ntdb, which
is corrected to match.

This means actually supplying a binary search implementation, rather than
relying on bsearch() from the standard library.  We follow the lead of the
asort module and steal^H^H^H^H^Hadapt the implementation from glibc.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/asearch/_info
ccan/asearch/asearch.c [new file with mode: 0644]
ccan/asearch/asearch.h
ccan/asearch/test/compile_fail-return-value-const.c
ccan/asearch/test/compile_fail-return-value.c
ccan/asearch/test/run-strings.c
ccan/asearch/test/run.c
ccan/ntdb/check.c