]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: quota - Use normal for-loop in quota_transaction_begin()
authorStephan Bosch <stephan.bosch@open-xchange.com>
Thu, 13 Feb 2025 01:09:52 +0000 (02:09 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 26 Feb 2025 10:45:00 +0000 (10:45 +0000)
src/plugins/quota/quota.c

index 1d13f7451f6fcfaf7885b0d45481cedcb3419918..4602f5c96524d4796de51e61df169763c4e3c6fe 100644 (file)
@@ -656,7 +656,8 @@ quota_get_resource(struct quota_root *root, struct mailbox *box,
 struct quota_transaction_context *quota_transaction_begin(struct mailbox *box)
 {
        struct quota_transaction_context *ctx;
-       struct quota_root *const *rootp;
+       struct quota_root *const *roots;
+       unsigned int roots_count, i;
 
        ctx = i_new(struct quota_transaction_context, 1);
        ctx->quota = box->list->ns->owner != NULL ?
@@ -664,19 +665,21 @@ struct quota_transaction_context *quota_transaction_begin(struct mailbox *box)
                quota_get_mail_user_quota(box->list->ns->user);
        i_assert(ctx->quota != NULL);
 
+       roots = array_get(&ctx->quota->all_roots, &roots_count);
+
        ctx->box = box;
        ctx->bytes_ceil = (uint64_t)-1;
        ctx->bytes_ceil2 = (uint64_t)-1;
        ctx->count_ceil = (uint64_t)-1;
 
        ctx->auto_updating = TRUE;
-       array_foreach(&ctx->quota->all_roots, rootp) {
-               if (!quota_root_is_visible(*rootp, ctx->box))
+       for (i = 0; i < roots_count; i++) {
+               if (!quota_root_is_visible(roots[i], ctx->box))
                        continue;
 
                const struct quota_root_settings *set = NULL;
                const char *error;
-               if (quota_root_settings_get(*rootp, box->event,
+               if (quota_root_settings_get(roots[i], box->event,
                                            &set, &error) < 0) {
                        e_error(ctx->box->event, "%s", error);
                        ctx->failed = TRUE;
@@ -695,8 +698,8 @@ struct quota_transaction_context *quota_transaction_begin(struct mailbox *box)
                   (An alternative could be to get the current quota usage
                   before and after the expunges, but that's more complicated
                   and probably isn't any better.) */
-               if (!(*rootp)->auto_updating ||
-                   quota_root_has_under_warnings(*rootp) != 0)
+               if (!(roots[i])->auto_updating ||
+                   quota_root_has_under_warnings(roots[i]) != 0)
                        ctx->auto_updating = FALSE;
        }