From b9eab66a79f8e3414d36769f5e880da513b6989f Mon Sep 17 00:00:00 2001 From: Josef 'Jeff' Sipek Date: Thu, 21 Jun 2018 09:45:03 -0400 Subject: [PATCH] lib: mempool - Improve p_realloc() panic message Most importantly, this differentiates it from the panic message that p_malloc() prints. --- src/lib/mempool.h | 3 ++- src/lib/test-mempool.c | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lib/mempool.h b/src/lib/mempool.h index 7e43b20d46..12ce2210ae 100644 --- a/src/lib/mempool.h +++ b/src/lib/mempool.h @@ -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); diff --git a/src/lib/test-mempool.c b/src/lib/test-mempool.c index 74495a877b..edf6e038e4 100644 --- a/src/lib/test-mempool.c +++ b/src/lib/test-mempool.c @@ -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); -- 2.47.3