From: Ondřej Surý Date: Fri, 9 Jul 2021 09:44:44 +0000 (+0200) Subject: Use isc_mem_get() and isc_mem_put() in isc_mem_total test X-Git-Tag: v9.17.17~40^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=63b06571b99ef89831d5612c029df82bea52a049;p=thirdparty%2Fbind9.git Use isc_mem_get() and isc_mem_put() in isc_mem_total test Previously, the isc_mem_allocate() and isc_mem_free() would be used for isc_mem_total test, but since we now use the real allocation size (sallocx, malloc_size, malloc_usable_size) to track the allocation size, it's impossible to get the test value right. Changing the test to use isc_mem_get() and isc_mem_put() will use the exact size provided, so the test would work again on all the platforms even when jemalloc is not being used. --- diff --git a/lib/isc/tests/mem_test.c b/lib/isc/tests/mem_test.c index c9602927f91..e848200e2ad 100644 --- a/lib/isc/tests/mem_test.c +++ b/lib/isc/tests/mem_test.c @@ -167,8 +167,8 @@ isc_mem_total_test(void **state) { for (i = 0; i < 100000; i++) { void *ptr; - ptr = isc_mem_allocate(mctx2, 2048); - isc_mem_free(mctx2, ptr); + ptr = isc_mem_get(mctx2, 2048); + isc_mem_put(mctx2, ptr, 2048); } after = isc_mem_total(mctx2); @@ -183,8 +183,8 @@ isc_mem_total_test(void **state) { for (i = 0; i < 100000; i++) { void *ptr; - ptr = isc_mem_allocate(test_mctx, 2048); - isc_mem_free(test_mctx, ptr); + ptr = isc_mem_get(test_mctx, 2048); + isc_mem_put(test_mctx, ptr, 2048); } after = isc_mem_total(test_mctx);