History log of /dovecot/src/lib/bsearch-insert-pos.h
Revision Date Author Comments Expand
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>

25480af2e21cf136e461ec802177f52b43154485 15-May-2013 Timo Sirainen <tss@iki.fi>

Added asserts to binary searches to make sure we don't go to infinite loop. Using idx=left+(right-left)/2 would have worked also to allow 4GB sizes, but since none of the places in the code are likely to reach 2GB we might as well just add an assert. (Also if they do reach 2GB, it could be possible that they could reach also above 4GB and cause problems. Better to see an early error.)

27a44fcfd8d19bffe0f267f20a2b5d3fe7600fdd 19-Aug-2012 Timo Sirainen <tss@iki.fi>

Removed CONTEXT_TYPE_SAFETY macro and reimplemented its functionality better. gcc/clang now gives a compiler error in many places if callback isn't exactly what was expected. It's also now much easier to add more of these checks.

/dovecot/src/anvil/anvil-connection.c /dovecot/src/auth/auth-request-handler.h /dovecot/src/auth/db-dict.c /dovecot/src/auth/db-ldap.c /dovecot/src/auth/db-sql.c /dovecot/src/config/config-connection.c /dovecot/src/doveadm/doveadm-mail-mailbox.c /dovecot/src/doveadm/doveadm-stats.c /dovecot/src/doveadm/doveadm.c /dovecot/src/imap/imap-fetch.h /dovecot/src/indexer/indexer-client.c /dovecot/src/lib-dns/dns-lookup.c /dovecot/src/lib-dns/dns-lookup.h /dovecot/src/lib-imap-storage/imap-msgpart.c /dovecot/src/lib-index/mail-index-util.c /dovecot/src/lib-lda/mail-send.c /dovecot/src/lib-mail/istream-header-filter.c /dovecot/src/lib-mail/istream-header-filter.h /dovecot/src/lib-mail/message-header-parser.h /dovecot/src/lib-mail/message-parser.h /dovecot/src/lib-mail/test-istream-header-filter.c /dovecot/src/lib-master/master-service.c /dovecot/src/lib-settings/settings.c /dovecot/src/lib-settings/settings.h /dovecot/src/lib-sql/sql-api.h /dovecot/src/lib-storage/index/dbox-multi/mdbox-purge.c /dovecot/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c /dovecot/src/lib-storage/index/imapc/imapc-mail-fetch.c /dovecot/src/lib-storage/index/index-mail-binary.c /dovecot/src/lib-storage/index/index-mail.c /dovecot/src/lib-storage/index/index-search.c /dovecot/src/lib-storage/index/index-sort-string.c /dovecot/src/lib-storage/index/index-thread.c /dovecot/src/lib-storage/index/maildir/maildir-mail.c /dovecot/src/lib-storage/index/maildir/maildir-storage.h /dovecot/src/lib-storage/index/maildir/maildir-sync-index.c /dovecot/src/lib-storage/index/mbox/mbox-mail.c /dovecot/src/lib-storage/index/pop3c/pop3c-sync.c /dovecot/src/lib-storage/mail-search.h /dovecot/src/lib-storage/mail-storage.h /dovecot/src/lib-storage/mailbox-header.c array.h bsearch-insert-pos.c bsearch-insert-pos.h child-wait.h connection.c ioloop.h istream.h macros.h module-dir.c ostream.h strfuncs.c strfuncs.h test-bsearch-insert-pos.c /dovecot/src/plugins/acl/acl-backend.c /dovecot/src/plugins/fts-squat/squat-uidlist.c /dovecot/src/plugins/pop3-migration/pop3-migration-plugin.c
b66d803de86bfb411165b3465b0d9ef64ecfe2a1 25-Jun-2012 Timo Sirainen <tss@iki.fi>

Avoid using (void)s by adding ATTR_NOWARN_UNUSED_RESULT attributes and other ways.

/dovecot/src/auth/auth-worker-server.h /dovecot/src/auth/passdb-blocking.c /dovecot/src/auth/userdb-blocking.c /dovecot/src/doveadm/doveadm-mail-expunge.c /dovecot/src/doveadm/doveadm-mail.c /dovecot/src/doveadm/dsync/dsync-brain-mailbox-tree.c /dovecot/src/doveadm/dsync/dsync-brain-mailbox.c /dovecot/src/doveadm/dsync/dsync-brain-mails.c /dovecot/src/doveadm/dsync/dsync-slave-pipe.c /dovecot/src/doveadm/dsync/dsync-slave.c /dovecot/src/doveadm/dsync/dsync-slave.h /dovecot/src/doveadm/dsync/dsync-transaction-log-scan.c /dovecot/src/imap-login/client.c /dovecot/src/imap/cmd-append.c /dovecot/src/imap/imap-client.c /dovecot/src/imap/imap-common.h /dovecot/src/imap/imap-search.c /dovecot/src/imap/imap-sync.c /dovecot/src/imap/imap-sync.h /dovecot/src/lib-dict/dict-client.c /dovecot/src/lib-dict/dict-file.c /dovecot/src/lib-imap-client/imapc-connection.c /dovecot/src/lib-imap/imap-bodystructure.c /dovecot/src/lib-index/mail-index-strmap.c /dovecot/src/lib-index/mail-index-transaction.c /dovecot/src/lib-index/mail-index.h /dovecot/src/lib-index/mail-transaction-log-file.c /dovecot/src/lib-mail/istream-binary-converter.c /dovecot/src/lib-mail/message-decoder.c /dovecot/src/lib-mail/message-parser.c /dovecot/src/lib-mail/rfc2231-parser.h /dovecot/src/lib-storage/index/dbox-multi/mdbox-mail.c /dovecot/src/lib-storage/index/dbox-single/sdbox-mail.c /dovecot/src/lib-storage/index/dbox-single/sdbox-sync.c /dovecot/src/lib-storage/index/index-storage.c /dovecot/src/lib-storage/index/index-thread.c /dovecot/src/lib-storage/index/index-transaction.c /dovecot/src/lib-storage/index/maildir/maildir-mail.c /dovecot/src/lib-storage/index/maildir/maildir-sync.c /dovecot/src/lib-storage/index/maildir/maildir-uidlist.c /dovecot/src/lib-storage/index/mbox/mbox-lock.c /dovecot/src/lib-storage/index/mbox/mbox-lock.h /dovecot/src/lib-storage/index/mbox/mbox-mail.c /dovecot/src/lib-storage/index/mbox/mbox-save.c /dovecot/src/lib-storage/index/mbox/mbox-storage.c /dovecot/src/lib-storage/index/mbox/mbox-sync.c /dovecot/src/lib-storage/index/pop3c/pop3c-client.c /dovecot/src/lib-storage/list/subscription-file.c /dovecot/src/lib-storage/mail-storage.c /dovecot/src/lib-storage/mail-storage.h /dovecot/src/lib-storage/mailbox-list.h /dovecot/src/lib-test/test-common.c bsearch-insert-pos.h file-dotlock.c file-dotlock.h iostream-rawlog.h istream-base64-encoder.c istream-data.c istream-private.h istream.c network.h /dovecot/src/login-common/client-common-auth.c /dovecot/src/login-common/client-common.h /dovecot/src/login-common/login-proxy.c /dovecot/src/login-common/ssl-proxy-gnutls.c /dovecot/src/login-common/ssl-proxy-openssl.c /dovecot/src/plugins/fts-lucene/fts-backend-lucene.c /dovecot/src/plugins/fts-solr/fts-backend-solr-old.c /dovecot/src/plugins/fts-solr/fts-backend-solr.c /dovecot/src/plugins/fts/fts-api-private.h /dovecot/src/plugins/fts/fts-api.c /dovecot/src/plugins/fts/fts-parser-script.c /dovecot/src/plugins/fts/fts-storage.c /dovecot/src/plugins/imap-acl/imap-acl-plugin.c /dovecot/src/plugins/imap-quota/imap-quota-plugin.c /dovecot/src/plugins/imap-zlib/imap-zlib-plugin.c /dovecot/src/pop3/pop3-client.c
91f07a54b8102a604dd6410831a73e917a20a06c 10-Dec-2009 Timo Sirainen <tss@iki.fi>

Compile fix for non-gcc. --HG-- branch : HEAD

0f184ee80e97f8a8312e9fab4f7f5a9d2187a18f 10-Jul-2009 Timo Sirainen <tss@iki.fi>

Added type safe array_bsearch_insert_pos(). --HG-- branch : HEAD

c25356d5978632df6203437e1953bcb29e0c736f 16-Sep-2007 Timo Sirainen <tss@iki.fi>

Changed .h ifdef/defines to use <NAME>_H format. --HG-- branch : HEAD

/dovecot/src/auth/auth-cache.h /dovecot/src/auth/auth-client-connection.h /dovecot/src/auth/auth-client-interface.h /dovecot/src/auth/auth-master-connection.h /dovecot/src/auth/auth-master-interface.h /dovecot/src/auth/auth-master-listener.h /dovecot/src/auth/auth-request-handler.h /dovecot/src/auth/auth-request.h /dovecot/src/auth/auth-stream.h /dovecot/src/auth/auth-worker-client.h /dovecot/src/auth/auth-worker-server.h /dovecot/src/auth/auth.h /dovecot/src/auth/common.h /dovecot/src/auth/db-ldap.h /dovecot/src/auth/db-passwd-file.h /dovecot/src/auth/db-sql.h /dovecot/src/auth/mech.h /dovecot/src/auth/mycrypt.h /dovecot/src/auth/otp-skey-common.h /dovecot/src/auth/passdb-blocking.h /dovecot/src/auth/passdb-cache.h /dovecot/src/auth/passdb.h /dovecot/src/auth/password-scheme.h /dovecot/src/auth/plain-common.h /dovecot/src/auth/userdb-blocking.h /dovecot/src/auth/userdb-static.h /dovecot/src/auth/userdb-vpopmail.h /dovecot/src/auth/userdb.h /dovecot/src/deliver/auth-client.h /dovecot/src/deliver/deliver.h /dovecot/src/deliver/duplicate.h /dovecot/src/deliver/mail-send.h /dovecot/src/deliver/smtp-client.h /dovecot/src/dict/dict-cache.h /dovecot/src/dict/dict-server.h /dovecot/src/imap-login/client-authenticate.h /dovecot/src/imap-login/client.h /dovecot/src/imap-login/imap-proxy.h /dovecot/src/imap/client.h /dovecot/src/imap/commands-util.h /dovecot/src/imap/commands.h /dovecot/src/imap/common.h /dovecot/src/imap/imap-expunge.h /dovecot/src/imap/imap-fetch.h /dovecot/src/imap/imap-messageset.h /dovecot/src/imap/imap-search.h /dovecot/src/imap/imap-sort.h /dovecot/src/imap/imap-status.h /dovecot/src/imap/imap-sync.h /dovecot/src/imap/imap-thread.h /dovecot/src/lib-auth/auth-client.h /dovecot/src/lib-auth/auth-server-connection.h /dovecot/src/lib-auth/auth-server-request.h /dovecot/src/lib-charset/charset-utf8.h /dovecot/src/lib-dict/dict-client.h /dovecot/src/lib-dict/dict-private.h /dovecot/src/lib-dict/dict-sql.h /dovecot/src/lib-dict/dict.h /dovecot/src/lib-imap/imap-base-subject.h /dovecot/src/lib-imap/imap-bodystructure.h /dovecot/src/lib-imap/imap-date.h /dovecot/src/lib-imap/imap-envelope.h /dovecot/src/lib-imap/imap-match.h /dovecot/src/lib-imap/imap-parser.h /dovecot/src/lib-imap/imap-quote.h /dovecot/src/lib-imap/imap-util.h /dovecot/src/lib-index/mail-cache-private.h /dovecot/src/lib-index/mail-cache.h /dovecot/src/lib-index/mail-hash.h /dovecot/src/lib-index/mail-index-private.h /dovecot/src/lib-index/mail-index-sync-private.h /dovecot/src/lib-index/mail-index-transaction-private.h /dovecot/src/lib-index/mail-index-view-private.h /dovecot/src/lib-index/mail-index.h /dovecot/src/lib-index/mail-transaction-log-private.h /dovecot/src/lib-index/mail-transaction-log.h /dovecot/src/lib-index/mailbox-list-index-private.h /dovecot/src/lib-index/mailbox-list-index.h /dovecot/src/lib-mail/istream-header-filter.h /dovecot/src/lib-mail/mail-types.h /dovecot/src/lib-mail/message-address.h /dovecot/src/lib-mail/message-date.h /dovecot/src/lib-mail/message-decoder.h /dovecot/src/lib-mail/message-header-decode.h /dovecot/src/lib-mail/message-header-parser.h /dovecot/src/lib-mail/message-id.h /dovecot/src/lib-mail/message-parser.h /dovecot/src/lib-mail/message-part-serialize.h /dovecot/src/lib-mail/message-search.h /dovecot/src/lib-mail/message-send.h /dovecot/src/lib-mail/message-size.h /dovecot/src/lib-mail/quoted-printable.h /dovecot/src/lib-mail/rfc822-parser.h /dovecot/src/lib-ntlm/ntlm-byteorder.h /dovecot/src/lib-ntlm/ntlm-des.h /dovecot/src/lib-ntlm/ntlm-encrypt.h /dovecot/src/lib-ntlm/ntlm-flags.h /dovecot/src/lib-ntlm/ntlm-message.h /dovecot/src/lib-ntlm/ntlm-types.h /dovecot/src/lib-ntlm/ntlm.h /dovecot/src/lib-otp/otp-dictionary.h /dovecot/src/lib-otp/otp-hash.h /dovecot/src/lib-otp/otp-parity.h /dovecot/src/lib-otp/otp-parse.h /dovecot/src/lib-otp/otp.h /dovecot/src/lib-settings/settings.h /dovecot/src/lib-sql/sql-api-private.h /dovecot/src/lib-sql/sql-api.h /dovecot/src/lib-storage/index/cydir/cydir-storage.h /dovecot/src/lib-storage/index/cydir/cydir-sync.h /dovecot/src/lib-storage/index/dbox/dbox-file.h /dovecot/src/lib-storage/index/dbox/dbox-index.h /dovecot/src/lib-storage/index/dbox/dbox-storage.h /dovecot/src/lib-storage/index/dbox/dbox-sync.h /dovecot/src/lib-storage/index/index-mail.h /dovecot/src/lib-storage/index/index-sort.h /dovecot/src/lib-storage/index/index-storage.h /dovecot/src/lib-storage/index/index-sync-changes.h /dovecot/src/lib-storage/index/maildir/maildir-filename.h /dovecot/src/lib-storage/index/maildir/maildir-keywords.h /dovecot/src/lib-storage/index/maildir/maildir-storage.h /dovecot/src/lib-storage/index/maildir/maildir-sync.h /dovecot/src/lib-storage/index/maildir/maildir-uidlist.h /dovecot/src/lib-storage/index/mbox/istream-raw-mbox.h /dovecot/src/lib-storage/index/mbox/mbox-file.h /dovecot/src/lib-storage/index/mbox/mbox-from.h /dovecot/src/lib-storage/index/mbox/mbox-lock.h /dovecot/src/lib-storage/index/mbox/mbox-md5.h /dovecot/src/lib-storage/index/mbox/mbox-storage.h /dovecot/src/lib-storage/index/mbox/mbox-sync-private.h /dovecot/src/lib-storage/list/index-mailbox-list.h /dovecot/src/lib-storage/list/mailbox-list-fs.h /dovecot/src/lib-storage/list/mailbox-list-maildir.h /dovecot/src/lib-storage/list/mailbox-list-subscriptions.h /dovecot/src/lib-storage/list/subscription-file.h /dovecot/src/lib-storage/mail-copy.h /dovecot/src/lib-storage/mail-error.h /dovecot/src/lib-storage/mail-namespace.h /dovecot/src/lib-storage/mail-search.h /dovecot/src/lib-storage/mail-storage-private.h /dovecot/src/lib-storage/mail-storage.h /dovecot/src/lib-storage/mailbox-list-private.h /dovecot/src/lib-storage/mailbox-list.h /dovecot/src/lib-storage/mailbox-tree.h array-decl.h array.h backtrace-string.h base64.h bsearch-insert-pos.h buffer.h close-keep-errno.h compat.h crc32.h data-stack.h env-util.h failures.h fd-close-on-exec.h fd-set-nonblock.h fdpass.h file-cache.h file-copy.h file-dotlock.h file-lock.h file-set-size.h hash.h hex-binary.h hex-dec.h hmac-md5.h home-expand.h hostpid.h imem.h ioloop-internal.h ioloop-iolist.h ioloop-notify-fd.h ioloop.h iostream-internal.h istream-internal.h istream-seekable.h istream-tee.h istream.h lib-signals.h lib.h macros.h md4.h md5.h mempool.h mkdir-parents.h mmap-util.h module-context.h module-dir.h mountpoint.h network.h nfs-workarounds.h ostream-crlf.h ostream-internal.h ostream.h primes.h printf-format-fix.h process-title.h randgen.h read-full.h restrict-access.h restrict-process-size.h safe-memset.h safe-mkdir.h safe-mkstemp.h sendfile-util.h seq-range-array.h sha1.h str-find.h str-sanitize.h str.h strescape.h strfuncs.h unichar.h unix-socket-create.h unlink-directory.h unlink-lockfiles.h utc-mktime.h utc-offset.h var-expand.h write-full.h /dovecot/src/login-common/client-common.h /dovecot/src/login-common/common.h /dovecot/src/login-common/login-proxy.h /dovecot/src/login-common/master.h /dovecot/src/login-common/sasl-server.h /dovecot/src/login-common/ssl-proxy.h /dovecot/src/master/askpass.h /dovecot/src/master/auth-process.h /dovecot/src/master/capabilities.h /dovecot/src/master/child-process.h /dovecot/src/master/common.h /dovecot/src/master/dict-process.h /dovecot/src/master/dup2-array.h /dovecot/src/master/listener.h /dovecot/src/master/log.h /dovecot/src/master/login-process.h /dovecot/src/master/mail-process.h /dovecot/src/master/master-login-interface.h /dovecot/src/master/master-settings.h /dovecot/src/master/ssl-init.h /dovecot/src/master/syslog-util.h /dovecot/src/plugins/acl/acl-api-private.h /dovecot/src/plugins/acl/acl-api.h /dovecot/src/plugins/acl/acl-backend-vfile.h /dovecot/src/plugins/acl/acl-cache.h /dovecot/src/plugins/acl/acl-plugin.h /dovecot/src/plugins/convert/convert-plugin.h /dovecot/src/plugins/convert/convert-storage.h /dovecot/src/plugins/expire/auth-client.h /dovecot/src/plugins/expire/expire-env.h /dovecot/src/plugins/expire/expire-plugin.h /dovecot/src/plugins/fts-lucene/fts-lucene-plugin.h /dovecot/src/plugins/fts-lucene/lucene-wrapper.h /dovecot/src/plugins/fts-squat/fts-squat-plugin.h /dovecot/src/plugins/fts-squat/squat-trie-private.h /dovecot/src/plugins/fts-squat/squat-trie.h /dovecot/src/plugins/fts-squat/squat-uidlist.h /dovecot/src/plugins/fts/fts-api-private.h /dovecot/src/plugins/fts/fts-api.h /dovecot/src/plugins/fts/fts-plugin.h /dovecot/src/plugins/imap-quota/imap-quota-plugin.h /dovecot/src/plugins/lazy-expunge/lazy-expunge-plugin.h /dovecot/src/plugins/mail-log/mail-log-plugin.h /dovecot/src/plugins/mbox-snarf/mbox-snarf-plugin.h /dovecot/src/plugins/quota/quota-fs.h /dovecot/src/plugins/quota/quota-plugin.h /dovecot/src/plugins/quota/quota-private.h /dovecot/src/plugins/quota/quota.h /dovecot/src/plugins/trash/trash-plugin.h /dovecot/src/plugins/zlib/istream-zlib.h /dovecot/src/plugins/zlib/zlib-plugin.h /dovecot/src/pop3-login/client-authenticate.h /dovecot/src/pop3-login/client.h /dovecot/src/pop3-login/pop3-proxy.h /dovecot/src/pop3/capability.h /dovecot/src/pop3/client.h /dovecot/src/pop3/commands.h /dovecot/src/pop3/common.h
810bf6e564ebef9655fc0ca3b5273fbb6022c098 20-Jul-2007 Timo Sirainen <tss@iki.fi>

Added BINARY_NUMBER_SEARCH() macro. --HG-- branch : HEAD

9f5f6bdc3fd1304720b5d541bc31eb21417af6cb 15-Mar-2007 Timo Sirainen <tss@iki.fi>

bsearch_insert_pos() API changed. Patch by Max Kellermann --HG-- branch : HEAD

8b1ff8af3123607dde63c516e007b47f6519c69a 21-Dec-2005 Timo Sirainen <tss@iki.fi>

Added bsearch_insert_pos(). Similar to bsearch(), but if value isn't found, returns the position where it would be inserted. --HG-- branch : HEAD