]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Don't waste 3 bytes of space in struct mail_index_record.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 1 Nov 2016 10:35:08 +0000 (12:35 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 9 Nov 2016 12:14:25 +0000 (14:14 +0200)
It was always supposed to be used mainly for keywords, but it got broken
many years ago and nobody noticed.

src/lib-index/mail-index-sync-ext.c
src/lib-index/mail-index-sync-keywords.c
src/lib-index/mail-index.h

index e6d475ba8b880e8b471c1a0488198999e12d7477..1203da77c68875784f0734e652e4d9735dd4a281 100644 (file)
@@ -176,7 +176,7 @@ static void sync_ext_reorder(struct mail_index_map *map, uint32_t ext_map_idx,
        /* we simply try to use the extensions with largest alignment
           requirement first. FIXME: if the extension sizes don't match
           alignment, this may not give the minimal layout. */
-       offset = sizeof(struct mail_index_record);
+       offset = MAIL_INDEX_RECORD_MIN_SIZE;
        max_align = sizeof(uint32_t);
        for (;;) {
                min_align = (uint16_t)-1;
@@ -213,6 +213,7 @@ static void sync_ext_reorder(struct mail_index_map *map, uint32_t ext_map_idx,
                offset += max_align - (offset % max_align);
        }
        new_record_size = offset;
+       i_assert(new_record_size >= sizeof(struct mail_index_record));
 
        /* copy the records to new buffer */
        new_buffer_size = map->rec_map->records_count * new_record_size;
index 7d5d0964f694ac1498bd6ed50176026374187699..d7f6c0675b04dc8d39052a6835deb97d5a98d2f1 100644 (file)
@@ -225,7 +225,7 @@ keywords_update_records(struct mail_index_sync_map_ctx *ctx,
        i_assert(data_offset < ext->record_size);
        data_offset += ext->record_offset;
 
-       i_assert(data_offset >= sizeof(struct mail_index_record));
+       i_assert(data_offset >= MAIL_INDEX_RECORD_MIN_SIZE);
 
        switch (type) {
        case MODIFY_ADD:
index 50e09e4b96c251c0d53743fdf31d75cf394b7434..2ead84827fc348b02324fd6232583ac17105f018 100644 (file)
@@ -105,6 +105,7 @@ struct mail_index_header {
        uint32_t day_first_uid[8];
 };
 
+#define MAIL_INDEX_RECORD_MIN_SIZE (sizeof(uint32_t) + sizeof(uint8_t))
 struct mail_index_record {
        uint32_t uid;
        uint8_t flags; /* enum mail_flags | enum mail_index_mail_flags */