summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2023-01-03 14:54:10 +0300
committerIvan Maidanski <ivmai@mail.ru>2023-01-03 14:54:10 +0300
commit522e7bb7e9100bb7d3c6202a4a1aac3330d32482 (patch)
tree25a746cb03078bf890d8478dd4b190dd4f3c40dc /tests
parent98200e4fff00d243c9bc65591ee794eaab1b6b48 (diff)
downloadbdwgc-522e7bb7e9100bb7d3c6202a4a1aac3330d32482.tar.gz
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/gctest.c14
1 files changed, 9 insertions, 5 deletions
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;
}
}