NULL,
index_mail_alloc,
index_header_lookup_init,
- index_header_lookup_ref,
- index_header_lookup_unref,
+ index_header_lookup_deinit,
index_storage_search_init,
index_storage_search_deinit,
index_storage_search_next_nonblock,
NULL,
dbox_mail_alloc,
index_header_lookup_init,
- index_header_lookup_ref,
- index_header_lookup_unref,
+ index_header_lookup_deinit,
index_storage_search_init,
index_storage_search_deinit,
index_storage_search_next_nonblock,
pool = pool_alloconly_create("index_header_lookup_ctx", 1024);
ctx = p_new(pool, struct index_header_lookup_ctx, 1);
ctx->ctx.box = box;
+ ctx->ctx.refcount = 1;
ctx->pool = pool;
ctx->count = count;
return ctx;
}
-void index_header_lookup_ref(struct mailbox_header_lookup_ctx *_ctx)
-{
- struct index_header_lookup_ctx *ctx =
- (struct index_header_lookup_ctx *)_ctx;
-
- pool_ref(ctx->pool);
-}
-
-void index_header_lookup_unref(struct mailbox_header_lookup_ctx *_ctx)
+void index_header_lookup_deinit(struct mailbox_header_lookup_ctx *_ctx)
{
struct index_header_lookup_ctx *ctx =
(struct index_header_lookup_ctx *)_ctx;
struct mailbox_header_lookup_ctx *
index_header_lookup_init(struct mailbox *box, const char *const headers[]);
-void index_header_lookup_ref(struct mailbox_header_lookup_ctx *ctx);
-void index_header_lookup_unref(struct mailbox_header_lookup_ctx *ctx);
+void index_header_lookup_deinit(struct mailbox_header_lookup_ctx *ctx);
struct mail_search_context *
index_storage_search_init(struct mailbox_transaction_context *t,
NULL,
index_mail_alloc,
index_header_lookup_init,
- index_header_lookup_ref,
- index_header_lookup_unref,
+ index_header_lookup_deinit,
index_storage_search_init,
index_storage_search_deinit,
index_storage_search_next_nonblock,
NULL,
index_mail_alloc,
index_header_lookup_init,
- index_header_lookup_ref,
- index_header_lookup_unref,
+ index_header_lookup_deinit,
index_storage_search_init,
index_storage_search_deinit,
index_storage_search_next_nonblock,
NULL,
index_mail_alloc,
index_header_lookup_init,
- index_header_lookup_ref,
- index_header_lookup_unref,
+ index_header_lookup_deinit,
index_storage_search_init,
index_storage_search_deinit,
index_storage_search_next_nonblock,
struct mailbox_header_lookup_ctx *
(*header_lookup_init)(struct mailbox *box,
const char *const headers[]);
- void (*header_lookup_ref)(struct mailbox_header_lookup_ctx *ctx);
- void (*header_lookup_unref)(struct mailbox_header_lookup_ctx *ctx);
+ void (*header_lookup_deinit)(struct mailbox_header_lookup_ctx *ctx);
struct mail_search_context *
(*search_init)(struct mailbox_transaction_context *t,
struct mailbox_header_lookup_ctx {
struct mailbox *box;
const char *const *headers;
+ int refcount;
};
/* Modules should use do "my_id = mail_storage_module_id++" and
void mailbox_header_lookup_ref(struct mailbox_header_lookup_ctx *ctx)
{
- ctx->box->v.header_lookup_ref(ctx);
+ i_assert(ctx->refcount > 0);
+ ctx->refcount++;
}
void mailbox_header_lookup_unref(struct mailbox_header_lookup_ctx **_ctx)
struct mailbox_header_lookup_ctx *ctx = *_ctx;
*_ctx = NULL;
- ctx->box->v.header_lookup_unref(ctx);
+
+ i_assert(ctx->refcount > 0);
+ if (--ctx->refcount > 0)
+ return;
+
+ ctx->box->v.header_lookup_deinit(ctx);
}
struct mail_search_context *
virtual_get_virtual_box_patterns,
virtual_mail_alloc,
index_header_lookup_init,
- index_header_lookup_ref,
- index_header_lookup_unref,
+ index_header_lookup_deinit,
virtual_search_init,
virtual_search_deinit,
virtual_search_next_nonblock,