From f7548d6d28c313cf80e6f3ef89aed16a19815df1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 11:51:24 +0200 Subject: Adding upstream version 1:2.3.19.1+dfsg1. Signed-off-by: Daniel Baumann --- src/lib/mempool.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/lib/mempool.c (limited to 'src/lib/mempool.c') diff --git a/src/lib/mempool.c b/src/lib/mempool.c new file mode 100644 index 0000000..a657481 --- /dev/null +++ b/src/lib/mempool.c @@ -0,0 +1,25 @@ +/* Copyright (c) 2005-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" + +/* The various implementations of pools API assume that they'll never be + asked for more than SSIZE_T_MAX bytes. This is a sanity check to make + sure nobody accidentally bumped the define beyond what's expected. */ +#if POOL_MAX_ALLOC_SIZE > SSIZE_T_MAX +#error "POOL_MAX_ALLOC_SIZE is too large" +#endif + +size_t pool_get_exp_grown_size(pool_t pool, size_t old_size, size_t min_size) +{ + size_t exp_size, easy_size; + + i_assert(old_size < min_size); + + exp_size = nearest_power(min_size); + easy_size = old_size + p_get_max_easy_alloc_size(pool); + + if (easy_size < exp_size && easy_size >= min_size) + exp_size = easy_size; + i_assert(exp_size >= min_size); + return exp_size; +} -- cgit v1.2.3