summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2023-01-31 19:52:40 +0300
committerIvan Maidanski <ivmai@mail.ru>2023-01-31 23:01:01 +0300
commit30d32b4e9ed35628c8c75faf6e639d256886e072 (patch)
tree6f486bf52ec1891d3df354c9d5293ff66ccd3907 /tests
parent1754cd484ea6ef1168134472adcca447b9246a48 (diff)
downloadbdwgc-30d32b4e9ed35628c8c75faf6e639d256886e072.tar.gz
Do not mix debug and non-debug allocations in disclaim tests
* include/gc/gc_disclaim.h (GC_finalized_malloc): Add comment that the debugging version of the function is missing. * tests/disclaim_bench.c (testobj_new): Use GC_malloc() instead of GC_NEW(). * tests/weakmap.c (weakmap_add, weakmap_new): Likewise. * tests/disclaim_bench.c (testobj_new): Use GC_register_finalizer_no_order() instead of GC_REGISTER_FINALIZER_NO_ORDER(). * tests/disclaim_bench.c (main): Use GC_malloc() instead of GC_MALLOC(). * tests/weakmap.c (weakmap_add, weakmap_new): Use GC_ptr_store_and_dirty() instead of GC_PTR_STORE_AND_DIRTY().
Diffstat (limited to 'tests')
-rw-r--r--tests/disclaim_bench.c8
-rw-r--r--tests/weakmap.c12
2 files changed, 10 insertions, 10 deletions
diff --git a/tests/disclaim_bench.c b/tests/disclaim_bench.c
index 8525063d..aab9275f 100644
--- a/tests/disclaim_bench.c
+++ b/tests/disclaim_bench.c
@@ -62,9 +62,9 @@ testobj_t testobj_new(int model)
switch (model) {
# ifndef GC_NO_FINALIZATION
case 0:
- obj = GC_NEW(struct testobj_s);
+ obj = (struct testobj_s *)GC_malloc(sizeof(struct testobj_s));
if (obj != NULL)
- GC_REGISTER_FINALIZER_NO_ORDER(obj, testobj_finalize,
+ GC_register_finalizer_no_order(obj, testobj_finalize,
&free_count, NULL, NULL);
break;
# endif
@@ -73,7 +73,7 @@ testobj_t testobj_new(int model)
&fclos);
break;
case 2:
- obj = GC_NEW(struct testobj_s);
+ obj = (struct testobj_s *)GC_malloc(sizeof(struct testobj_s));
break;
default:
exit(-1);
@@ -127,7 +127,7 @@ int main(int argc, char **argv)
if (GC_get_find_leak())
printf("This test program is not designed for leak detection mode\n");
- keep_arr = (testobj_t *)GC_MALLOC(sizeof(void *) * KEEP_CNT);
+ keep_arr = (testobj_t *)GC_malloc(sizeof(void *) * KEEP_CNT);
if (NULL == keep_arr) {
fprintf(stderr, "Out of memory!\n");
exit(3);
diff --git a/tests/weakmap.c b/tests/weakmap.c
index 8bcd1cfd..8a9336e1 100644
--- a/tests/weakmap.c
+++ b/tests/weakmap.c
@@ -208,13 +208,13 @@ void *weakmap_add(struct weakmap *wm, void *obj, size_t obj_size)
GC_end_stubborn_change(new_base);
/* Add the object to the map. */
- new_link = GC_NEW(struct weakmap_link);
+ new_link = (struct weakmap_link *)GC_malloc(sizeof(struct weakmap_link));
CHECK_OOM(new_link);
new_link->obj = GC_get_find_leak() ? (GC_word)new_obj
: GC_HIDE_POINTER(new_obj);
new_link->next = *first;
GC_END_STUBBORN_CHANGE(new_link);
- GC_PTR_STORE_AND_DIRTY(first, new_link);
+ GC_ptr_store_and_dirty(first, new_link);
weakmap_unlock(wm, h);
AO_fetch_and_add1(&stat_added);
# ifdef DEBUG_DISCLAIM_WEAKMAP
@@ -279,7 +279,7 @@ int GC_CALLBACK weakmap_disclaim(void *obj_base)
break;
my_assert(memcmp(old_obj, obj, wm->key_size) != 0);
}
- GC_PTR_STORE_AND_DIRTY(link, (*link)->next);
+ GC_ptr_store_and_dirty(link, (*link)->next);
weakmap_unlock(wm, h);
return 0;
}
@@ -287,7 +287,7 @@ int GC_CALLBACK weakmap_disclaim(void *obj_base)
struct weakmap *weakmap_new(size_t capacity, size_t key_size, size_t obj_size,
unsigned weakobj_kind)
{
- struct weakmap *wm = GC_NEW(struct weakmap);
+ struct weakmap *wm = (struct weakmap *)GC_malloc(sizeof(struct weakmap));
CHECK_OOM(wm);
# ifdef GC_PTHREADS
@@ -303,8 +303,8 @@ struct weakmap *weakmap_new(size_t capacity, size_t key_size, size_t obj_size,
wm->obj_size = obj_size;
wm->capacity = capacity;
wm->weakobj_kind = weakobj_kind;
- GC_PTR_STORE_AND_DIRTY(&wm->links,
- GC_MALLOC(sizeof(struct weakmap_link *) * capacity));
+ GC_ptr_store_and_dirty(&wm->links,
+ GC_malloc(sizeof(struct weakmap_link *) * capacity));
CHECK_OOM(wm->links);
return wm;
}