1f0b3ea95f45146b6860a37f43bc02b62891e354 |
|
22-Sep-2014 |
Phil Carmody <phil@dovecot.fi> |
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> |