# HG changeset patch # User Aki Tuomi # Date 1490171578 -7200 # Node ID 0bb58080e0a6a1ef4186e2c06f6a33492f3ff96e # Parent 7d4264ff0d9a81969b72ca36fcc517beaca85f4e lib-dict: Use dict-fail iterator and transaction when missing from dict driver diff -r 7d4264ff0d9a -r 0bb58080e0a6 src/lib-dict/dict.c --- a/src/lib-dict/dict.c Wed Mar 22 12:05:32 2017 +0200 +++ b/src/lib-dict/dict.c Wed Mar 22 10:32:58 2017 +0200 @@ -7,7 +7,6 @@ #include "dict-private.h" static ARRAY(struct dict *) dict_drivers; -static struct dict_iterate_context dict_iter_unsupported; static struct dict *dict_driver_lookup(const char *name) { @@ -187,8 +186,6 @@ bool dict_iterate(struct dict_iterate_context *ctx, const char **key_r, const char **value_r) { - if (ctx == &dict_iter_unsupported) - return FALSE; if (ctx->max_rows > 0 && ctx->row_count >= ctx->max_rows) { /* row count was limited */ ctx->has_more = FALSE; @@ -227,12 +224,13 @@ ctx->dict->iter_count--; *_ctx = NULL; - return ctx == &dict_iter_unsupported ? -1 : - ctx->dict->v.iterate_deinit(ctx); + return ctx->dict->v.iterate_deinit(ctx); } struct dict_transaction_context *dict_transaction_begin(struct dict *dict) { + if (dict->v.transaction_init == NULL) + return &dict_transaction_unsupported; return dict->v.transaction_init(dict); }