From: Timo Sirainen Date: Thu, 12 Nov 2020 16:01:18 +0000 (+0200) Subject: lib-index: test-mail-transaction-log-view - Move test_transaction_log_file_add() X-Git-Tag: 2.3.14.rc1~322 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8e6fab92e6208eec71673e87db07054680e8530d;p=thirdparty%2Fdovecot%2Fcore.git lib-index: test-mail-transaction-log-view - Move test_transaction_log_file_add() --- diff --git a/src/lib-index/test-mail-transaction-log-view.c b/src/lib-index/test-mail-transaction-log-view.c index 24fbc9724a..a3a28e8f21 100644 --- a/src/lib-index/test-mail-transaction-log-view.c +++ b/src/lib-index/test-mail-transaction-log-view.c @@ -9,6 +9,32 @@ static struct mail_transaction_log *log; static struct mail_transaction_log_view *view; +static void +test_transaction_log_file_add(uint32_t file_seq) +{ + struct mail_transaction_log_file **p, *file; + + file = i_new(struct mail_transaction_log_file, 1); + file->hdr.file_seq = file_seq; + file->hdr.hdr_size = file->sync_offset = sizeof(file->hdr); + file->hdr.prev_file_seq = file_seq - 1; + file->hdr.prev_file_offset = (uint32_t)-1; + file->log = log; + file->fd = -1; + file->buffer = buffer_create_dynamic(default_pool, 256); + file->buffer_offset = file->hdr.hdr_size; + + /* files must be sorted by file_seq */ + for (p = &log->files; *p != NULL; p = &(*p)->next) { + if ((*p)->hdr.file_seq > file->hdr.file_seq) { + file->next = *p; + break; + } + } + *p = file; + log->head = file; +} + void mail_index_set_error(struct mail_index *index ATTR_UNUSED, const char *fmt ATTR_UNUSED, ...) { @@ -64,32 +90,6 @@ void mail_transaction_update_modseq(const struct mail_transaction_header *hdr AT *cur_modseq += 1; } -static void -test_transaction_log_file_add(uint32_t file_seq) -{ - struct mail_transaction_log_file **p, *file; - - file = i_new(struct mail_transaction_log_file, 1); - file->hdr.file_seq = file_seq; - file->hdr.hdr_size = file->sync_offset = sizeof(file->hdr); - file->hdr.prev_file_seq = file_seq - 1; - file->hdr.prev_file_offset = (uint32_t)-1; - file->log = log; - file->fd = -1; - file->buffer = buffer_create_dynamic(default_pool, 256); - file->buffer_offset = file->hdr.hdr_size; - - /* files must be sorted by file_seq */ - for (p = &log->files; *p != NULL; p = &(*p)->next) { - if ((*p)->hdr.file_seq > file->hdr.file_seq) { - file->next = *p; - break; - } - } - *p = file; - log->head = file; -} - static bool view_is_file_refed(uint32_t file_seq) { struct mail_transaction_log_file *const *files;