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.
This commit is contained in:
Ondřej Surý
2021-07-09 11:44:44 +02:00
parent d3676a1fc5
commit 63b06571b9

View 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);