dovecot-2.2: mail-index: new helper macro with more user-friendl...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jun 2 11:53:55 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/c83ef1042679
changeset: 17427:c83ef1042679
user:      Phil Carmody <phil at dovecot.fi>
date:      Mon Jun 02 14:50:34 2014 +0300
description:
mail-index: new helper macro with more user-friendly semantics
As the record ids range from 1..records_count, but the data is
stored as if in a C-style 0-based array, current clients of
MAIL_INDEX_MAP_IDX() must subtract 1 from the index themselved.

New MAIL_INDEX_REC_AT_SEQ() macro does the subtraction for you,
it gives you (the address of) the record from a seq number.

Uglified users of the former will be migrated to the latter.

Signed-off-by: Phil Carmody <phil at dovecot.fi>

diffstat:

 src/lib-index/mail-index-private.h |  3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diffs (13 lines):

diff -r 0b653039d3b9 -r c83ef1042679 src/lib-index/mail-index-private.h
--- a/src/lib-index/mail-index-private.h	Mon Jun 02 14:50:34 2014 +0300
+++ b/src/lib-index/mail-index-private.h	Mon Jun 02 14:50:34 2014 +0300
@@ -37,6 +37,9 @@
 #define MAIL_INDEX_MAP_IDX(map, idx) \
 	((struct mail_index_record *) \
 	 PTR_OFFSET((map)->rec_map->records, (idx) * (map)->hdr.record_size))
+#define MAIL_INDEX_REC_AT_SEQ(map, seq)					\
+	((struct mail_index_record *)					\
+	 PTR_OFFSET((map)->rec_map->records, ((seq)-1) * (map)->hdr.record_size))
 
 #define MAIL_TRANSACTION_FLAG_UPDATE_IS_INTERNAL(u) \
 	((((u)->add_flags | (u)->remove_flags) & MAIL_INDEX_FLAGS_MASK) == 0 && \


More information about the dovecot-cvs mailing list