summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2023-01-31 19:52:40 +0300
committerIvan Maidanski <ivmai@mail.ru>2023-03-14 11:40:23 +0300
commitd2b01b2d0758bc0d29855431e1aab28a42198c1b (patch)
tree96fce736b9354502e2cb7a0467ee7c1a702fcfc2
parent1d22f1697cfd6279e6a987b339b7810b9d1180b8 (diff)
downloadbdwgc-d2b01b2d0758bc0d29855431e1aab28a42198c1b.tar.gz
Do not mix debug and non-debug allocations in disclaim tests
(a cherry-pick of commit 30d32b4e9 from 'master') * include/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/disclaim_weakmap_test.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().
-rw-r--r--include/gc_disclaim.h1
-rw-r--r--tests/disclaim_bench.c8
-rw-r--r--tests/disclaim_weakmap_test.c12
3 files changed, 11 insertions, 10 deletions
diff --git a/include/gc_disclaim.h b/include/gc_disclaim.h
index f2942cdb..6394b05e 100644
--- a/include/gc_disclaim.h
+++ b/include/gc_disclaim.h
@@ -63,6 +63,7 @@ struct GC_finalizer_closure {
/* slightly bigger than the specified allocation size, and that GC_base */
/* result points to a word prior to the start of the allocated object. */
/* The disclaim procedure is not invoked in the leak-finding mode. */
+/* There is no debugging version of this allocation API. */
GC_API GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1) void * GC_CALL
GC_finalized_malloc(size_t /*size*/,
const struct GC_finalizer_closure * /*fc*/) GC_ATTR_NONNULL(2);
diff --git a/tests/disclaim_bench.c b/tests/disclaim_bench.c
index 28feb1a5..6a7b0903 100644
--- a/tests/disclaim_bench.c
+++ b/tests/disclaim_bench.c
@@ -63,9 +63,9 @@ testobj_t testobj_new(int model)
testobj_t obj;
switch (model) {
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;
case 1:
@@ -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);
@@ -124,7 +124,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/disclaim_weakmap_test.c b/tests/disclaim_weakmap_test.c
index fd811fef..05461035 100644
--- a/tests/disclaim_weakmap_test.c
+++ b/tests/disclaim_weakmap_test.c
@@ -214,13 +214,13 @@ void *weakmap_add(struct weakmap *wm, void *obj)
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
@@ -285,7 +285,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;
}
@@ -293,7 +293,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
@@ -309,8 +309,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;
}