diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
commit | f7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch) | |
tree | a3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /src/lib-dict/dict-transaction-memory.h | |
parent | Initial commit. (diff) | |
download | dovecot-upstream.tar.xz dovecot-upstream.zip |
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/lib-dict/dict-transaction-memory.h')
-rw-r--r-- | src/lib-dict/dict-transaction-memory.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/lib-dict/dict-transaction-memory.h b/src/lib-dict/dict-transaction-memory.h new file mode 100644 index 0000000..2164c1e --- /dev/null +++ b/src/lib-dict/dict-transaction-memory.h @@ -0,0 +1,38 @@ +#ifndef DICT_TRANSACTION_MEMORY_H +#define DICT_TRANSACTION_MEMORY_H + +#include "dict-private.h" + +enum dict_change_type { + DICT_CHANGE_TYPE_SET, + DICT_CHANGE_TYPE_UNSET, + DICT_CHANGE_TYPE_INC +}; + +struct dict_transaction_memory_change { + enum dict_change_type type; + const char *key; + union { + const char *str; + long long diff; + } value; +}; + +struct dict_transaction_memory_context { + struct dict_transaction_context ctx; + pool_t pool; + ARRAY(struct dict_transaction_memory_change) changes; +}; + +void dict_transaction_memory_init(struct dict_transaction_memory_context *ctx, + struct dict *dict, pool_t pool); +void dict_transaction_memory_rollback(struct dict_transaction_context *ctx); + +void dict_transaction_memory_set(struct dict_transaction_context *ctx, + const char *key, const char *value); +void dict_transaction_memory_unset(struct dict_transaction_context *ctx, + const char *key); +void dict_transaction_memory_atomic_inc(struct dict_transaction_context *ctx, + const char *key, long long diff); + +#endif |