]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: mempool - Improve p_realloc() panic message
authorJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Thu, 21 Jun 2018 13:45:03 +0000 (09:45 -0400)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 4 Jul 2018 08:28:51 +0000 (08:28 +0000)
Most importantly, this differentiates it from the panic message that
p_malloc() prints.

src/lib/mempool.h
src/lib/test-mempool.c

index 7e43b20d46fb6b04faa58812951e85e66d768794..12ce2210aed1186e9ee4c35dd482605f9a406895 100644 (file)
@@ -111,7 +111,8 @@ static inline void * ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
 p_realloc(pool_t pool, void *mem, size_t old_size, size_t new_size)
 {
        if (unlikely(new_size == 0 || new_size > POOL_MAX_ALLOC_SIZE))
-               i_panic("Trying to allocate %" PRIuSIZE_T " bytes", new_size);
+               i_panic("Trying to reallocate %" PRIuSIZE_T " -> %" PRIuSIZE_T " bytes",
+                       old_size, new_size);
 
        if (mem == NULL)
                return pool->v->malloc(pool, new_size);
index 74495a877bf550861b99b6afb2dcb47524383a62..edf6e038e438d207cccd60d2b5fe6c209ff176d0 100644 (file)
@@ -57,23 +57,23 @@ enum fatal_test_state fatal_mempool(unsigned int stage)
                m2 = p_new(&test_pool, uint32_t, BIG_MAX / sizeof(uint32_t) + 1);
                return FATAL_TEST_FAILURE;
        case 2: /* grow */
-               test_expect_fatal_string("Trying to allocate");
+               test_expect_fatal_string("Trying to reallocate");
                m1 = p_realloc_type(&test_pool, m1, uint32max_array_t,
                                    LITTLE_MAX + 2, LITTLE_MAX + 3);
                return FATAL_TEST_FAILURE;
        case 3:
-               test_expect_fatal_string("Trying to allocate");
+               test_expect_fatal_string("Trying to reallocate");
                m2 = p_realloc_type(&test_pool, m2, uint32_t,
                                    BIG_MAX / sizeof(uint32_t),
                                    BIG_MAX / sizeof(uint32_t) + 1);
                return FATAL_TEST_FAILURE;
        case 4: /* shrink */
-               test_expect_fatal_string("Trying to allocate");
+               test_expect_fatal_string("Trying to reallocate");
                m1 = p_realloc_type(&test_pool, m1, uint32max_array_t,
                                    LITTLE_MAX + 3, LITTLE_MAX + 2);
                return FATAL_TEST_FAILURE;
        case 5:
-               test_expect_fatal_string("Trying to allocate");
+               test_expect_fatal_string("Trying to reallocate");
                m2 = p_realloc_type(&test_pool, m2, uint32_t,
                                    BIG_MAX / sizeof(uint32_t) + 2,
                                    BIG_MAX / sizeof(uint32_t) + 1);