dovecot-2.0: Moved mail_index_keywords_*() to mail-index.c.
dovecot at dovecot.org
dovecot at dovecot.org
Mon Jul 13 20:20:28 EEST 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/ed9b4bc28913
changeset: 9613:ed9b4bc28913
user: Timo Sirainen <tss at iki.fi>
date: Mon Jul 13 13:16:45 2009 -0400
description:
Moved mail_index_keywords_*() to mail-index.c.
diffstat:
2 files changed, 52 insertions(+), 90 deletions(-)
src/lib-index/mail-index-transaction.c | 90 --------------------------------
src/lib-index/mail-index.c | 52 ++++++++++++++++++
diffs (162 lines):
diff -r 2cab7f501986 -r ed9b4bc28913 src/lib-index/mail-index-transaction.c
--- a/src/lib-index/mail-index-transaction.c Mon Jul 13 13:13:03 2009 -0400
+++ b/src/lib-index/mail-index-transaction.c Mon Jul 13 13:16:45 2009 -0400
@@ -1094,96 +1094,6 @@ int mail_index_atomic_inc_ext(struct mai
return diff32;
}
-struct mail_keywords *
-mail_index_keywords_create(struct mail_index *index,
- const char *const keywords[])
-{
- struct mail_keywords *k;
- unsigned int src, dest, i, count;
-
- count = str_array_length(keywords);
- if (count == 0) {
- k = i_new(struct mail_keywords, 1);
- k->index = index;
- k->refcount = 1;
- return k;
- }
-
- /* @UNSAFE */
- k = i_malloc(sizeof(struct mail_keywords) +
- (sizeof(k->idx) * (count-1)));
- k->index = index;
- k->refcount = 1;
-
- /* look up the keywords from index. they're never removed from there
- so we can permanently store indexes to them. */
- for (src = dest = 0; src < count; src++) {
- mail_index_keyword_lookup_or_create(index, keywords[src],
- &k->idx[dest]);
- /* ignore if this is a duplicate */
- for (i = 0; i < src; i++) {
- if (k->idx[i] == k->idx[dest])
- break;
- }
- if (i == src)
- dest++;
- }
- k->count = dest;
- return k;
-}
-
-struct mail_keywords *
-mail_index_keywords_create_from_indexes(struct mail_index *index,
- const ARRAY_TYPE(keyword_indexes)
- *keyword_indexes)
-{
- struct mail_keywords *k;
- const unsigned int *indexes;
- unsigned int src, dest, i, count;
-
- indexes = array_get(keyword_indexes, &count);
- if (count == 0) {
- k = i_new(struct mail_keywords, 1);
- k->index = index;
- k->refcount = 1;
- return k;
- }
-
- /* @UNSAFE */
- k = i_malloc(sizeof(struct mail_keywords) +
- (sizeof(k->idx) * (count-1)));
- k->index = index;
- k->refcount = 1;
-
- /* copy but skip duplicates */
- for (src = dest = 0; src < count; src++) {
- for (i = 0; i < src; i++) {
- if (k->idx[i] == indexes[src])
- break;
- }
- if (i == src)
- k->idx[dest++] = indexes[src];
- }
- k->count = dest;
- return k;
-}
-
-void mail_index_keywords_ref(struct mail_keywords *keywords)
-{
- keywords->refcount++;
-}
-
-void mail_index_keywords_unref(struct mail_keywords **_keywords)
-{
- struct mail_keywords *keywords = *_keywords;
-
- i_assert(keywords->refcount > 0);
-
- *_keywords = NULL;
- if (--keywords->refcount == 0)
- i_free(keywords);
-}
-
static bool
keyword_update_has_changes(struct mail_index_transaction *t, uint32_t seq,
enum modify_type modify_type,
diff -r 2cab7f501986 -r ed9b4bc28913 src/lib-index/mail-index.c
--- a/src/lib-index/mail-index.c Mon Jul 13 13:13:03 2009 -0400
+++ b/src/lib-index/mail-index.c Mon Jul 13 13:16:45 2009 -0400
@@ -258,6 +258,58 @@ const ARRAY_TYPE(keywords) *mail_index_g
return &index->keywords;
}
+struct mail_keywords *
+mail_index_keywords_create_from_indexes(struct mail_index *index,
+ const ARRAY_TYPE(keyword_indexes)
+ *keyword_indexes)
+{
+ struct mail_keywords *k;
+ const unsigned int *indexes;
+ unsigned int src, dest, i, count;
+
+ indexes = array_get(keyword_indexes, &count);
+ if (count == 0) {
+ k = i_new(struct mail_keywords, 1);
+ k->index = index;
+ k->refcount = 1;
+ return k;
+ }
+
+ /* @UNSAFE */
+ k = i_malloc(sizeof(struct mail_keywords) +
+ (sizeof(k->idx) * (count-1)));
+ k->index = index;
+ k->refcount = 1;
+
+ /* copy but skip duplicates */
+ for (src = dest = 0; src < count; src++) {
+ for (i = 0; i < src; i++) {
+ if (k->idx[i] == indexes[src])
+ break;
+ }
+ if (i == src)
+ k->idx[dest++] = indexes[src];
+ }
+ k->count = dest;
+ return k;
+}
+
+void mail_index_keywords_ref(struct mail_keywords *keywords)
+{
+ keywords->refcount++;
+}
+
+void mail_index_keywords_unref(struct mail_keywords **_keywords)
+{
+ struct mail_keywords *keywords = *_keywords;
+
+ i_assert(keywords->refcount > 0);
+
+ *_keywords = NULL;
+ if (--keywords->refcount == 0)
+ i_free(keywords);
+}
+
int mail_index_try_open_only(struct mail_index *index)
{
i_assert(index->fd == -1);
More information about the dovecot-cvs
mailing list