Add tree walking debug function
This commit is contained in:
@ -46,6 +46,16 @@ void reref_destructor(void *a, void *ctx_raw) {
|
||||
refcount_context_ref(ctx, a);
|
||||
}
|
||||
|
||||
UNUSED bool print_tree_walk_callback(void *obj, const RefcountList *trail,
|
||||
void *ignored) {
|
||||
size_t len = refcount_list_length(trail);
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
fprintf(stderr, " ");
|
||||
}
|
||||
fprintf(stderr, "- %p\n", obj);
|
||||
return false;
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv) {
|
||||
struct ContextAndFlag ctx_and_flag = {.should_be_doing_gc = false};
|
||||
|
||||
@ -153,6 +163,8 @@ int main(int argc, const char **argv) {
|
||||
assert(refcount_context_garbage_collect(c) == 0);
|
||||
assert(refcount_context_unref(c, a_with_destructor));
|
||||
assert(!refcount_context_is_doing_gc(c));
|
||||
/* refcount_debug_context_walk_tree(c, a_with_destructor, */
|
||||
/* print_tree_walk_callback, NULL); */
|
||||
ctx_and_flag.should_be_doing_gc = true;
|
||||
assert(refcount_context_garbage_collect(c) == 26);
|
||||
ctx_and_flag.should_be_doing_gc = false;
|
||||
|
Reference in New Issue
Block a user