From aa047be6b95aa1694c84f326ef78775f97283cb7 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Tue, 14 Mar 2017 19:00:32 +0300 Subject: [PATCH] Zero size memory pool allocations have been disabled in unit test becuase they are handled incorrectly with the -DNXT_DEBUG_MEMORY=1 option. --- test/nxt_mem_cache_pool_unit_test.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/nxt_mem_cache_pool_unit_test.c b/test/nxt_mem_cache_pool_unit_test.c index 6b35f5af..b9da5099 100644 --- a/test/nxt_mem_cache_pool_unit_test.c +++ b/test/nxt_mem_cache_pool_unit_test.c @@ -13,7 +13,7 @@ nxt_mem_cache_pool_unit_test(nxt_thread_t *thr, nxt_uint_t runs, { void **blocks; size_t total; - uint32_t size; + uint32_t value, size; nxt_uint_t i, n; nxt_mem_cache_pool_t *pool; @@ -37,17 +37,23 @@ nxt_mem_cache_pool_unit_test(nxt_thread_t *thr, nxt_uint_t runs, return NXT_ERROR; } - size = 0; + value = 0; for (i = 0; i < runs; i++) { total = 0; for (n = 0; n < nblocks; n++) { - size = nxt_murmur_hash2(&size, sizeof(uint32_t)); + value = nxt_murmur_hash2(&value, sizeof(uint32_t)); - total += size & max_size; - blocks[n] = nxt_mem_cache_alloc(pool, size & max_size); + size = value & max_size; + + if (size == 0) { + size++; + } + + total += size; + blocks[n] = nxt_mem_cache_alloc(pool, size); if (blocks[n] == NULL) { nxt_log_error(NXT_LOG_NOTICE, thr->log,