]> git.ipfire.org Git - thirdparty/dovecot/core.git/commit
lib: bsearch - make BINARY_NUMBER_SEARCH more widely usable
authorPhil Carmody <phil@dovecot.fi>
Mon, 22 Sep 2014 12:56:31 +0000 (15:56 +0300)
committerPhil Carmody <phil@dovecot.fi>
Mon, 22 Sep 2014 12:56:31 +0000 (15:56 +0300)
commit1f0b3ea95f45146b6860a37f43bc02b62891e354
treea99c0e1a721b55840dc674f759d943f8f83ec706
parent02a38d8590dd692e5cd35f34f3b634f4a84f94e8
lib: bsearch - make BINARY_NUMBER_SEARCH more widely usable
This template is more widely usable if we do not hard-code into it the
method of accessing the value being compared. For the default case
we already use, this accessor is just a simple array dereferencing
macro.

As rewriting with the array access happens in the preprocessor, the
code generated is completely unchanged.

Expected future use:

:  #define MY_GETTER(array, index) ((array)[(index)].index_field)
:  #define MY_BINARY_SEARCH(data, count, value, idx_r)                  \
:          BINARY_NUMERIC_SEARCH(MY_GETTER, data, count, value, idx_r);

Signed-off-by: Phil Carmody <phil@dovecot.fi>
src/lib/bsearch-insert-pos.h