]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use isc_mem_get() and isc_mem_put() in isc_mem_total test
authorOndřej Surý <ondrej@sury.org>
Fri, 9 Jul 2021 09:44:44 +0000 (11:44 +0200)
committerOndřej Surý <ondrej@sury.org>
Fri, 9 Jul 2021 13:58:02 +0000 (15:58 +0200)
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.

lib/isc/tests/mem_test.c

index c9602927f9177e5616508c5f4faa119588cc04e5..e848200e2adbb7d9d1b150da72cf5a58044e074a 100644 (file)
@@ -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);