cwist
Modern C web framework with libttak runtime
Loading...
Searching...
No Matches
gc_internal.h File Reference

Internal bridge between the allocator and the epoch GC wrapper. More...

#include <stdbool.h>
Include dependency graph for gc_internal.h:

Go to the source code of this file.

Functions

bool cwist_gc_reg_untrack (void *ptr)
 Detach a pointer previously handed to a GC context through cwist_reg_ptr()/cwist_reg_ptr_sized(), without freeing it.
 

Detailed Description

Internal bridge between the allocator and the epoch GC wrapper.

Not part of the installed public API: this declaration is shared only between src/core/mem/alloc.c and src/core/mem/gc.c.

Definition in file gc_internal.h.

Function Documentation

◆ cwist_gc_reg_untrack()

bool cwist_gc_reg_untrack ( void *  ptr)

Detach a pointer previously handed to a GC context through cwist_reg_ptr()/cwist_reg_ptr_sized(), without freeing it.

cwist_free() calls this on every block so an explicit free of a registered pointer is safe (the owning context would otherwise free it again at cwist_gc_shutdown()). For blocks that were never registered it is a cheap no-op.

Parameters
ptrBlock being freed; a no-op when NULL.
Returns
true when ptr was registered and has been detached.

Detach a pointer previously handed to a GC context through cwist_reg_ptr()/cwist_reg_ptr_sized(), without freeing it.

Removes the pointer from the registry and from its owner's libttak mem_tree (when that context is still initialized) so a later cwist_gc_shutdown() of the context no longer touches the block. Called by cwist_free() so an explicit free of a registered pointer is always safe, and by cwist_reg_ptr_sized() when registration moves to another context.

Parameters
ptrBlock to detach; a no-op when NULL.
Returns
true when ptr was registered and has been detached.

Definition at line 113 of file gc.c.

References cwist_gc::impl, and cwist_gc::initialized.