From 522e7bb7e9100bb7d3c6202a4a1aac3330d32482 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 3 Jan 2023 14:54:10 +0300 Subject: Increment allocated objects count after GC_memalign in gctest * tests/gctest.c [!DBG_HDRS_ALL] (run_one_test): Check no out-of-memory in GC_malloc(17); define p local variable (of void* type) instead of result one; call CHECK_OUT_OF_MEMORY() and increment collectable_count after GC_memalign() call. --- tests/gctest.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/gctest.c b/tests/gctest.c index 066c5c11..ba60f108 100644 --- a/tests/gctest.c +++ b/tests/gctest.c @@ -1551,16 +1551,20 @@ void run_one_test(void) } { size_t i; + void *p; - (void)GC_malloc(17); + p = GC_malloc(17); + CHECK_OUT_OF_MEMORY(p); AO_fetch_and_add1(&collectable_count); + /* TODO: GC_memalign and friends are not tested well. */ for (i = sizeof(GC_word); i < 512; i *= 2) { - GC_word result = (GC_word) GC_memalign(i, 17); - - if (result % i != 0 || result == 0 || *(int *)result != 0) { + p = GC_memalign(i, 17); + CHECK_OUT_OF_MEMORY(p); + AO_fetch_and_add1(&collectable_count); + if ((word)p % i != 0 || *(int *)p != 0) { GC_printf("GC_memalign(%u,17) produced incorrect result: %p\n", - (unsigned)i, (void *)result); + (unsigned)i, p); FAIL; } } -- cgit v1.2.1