Initial garbage colletor implementation

This commit is contained in:
2025-08-30 21:21:02 -07:00
parent 80e3f1a916
commit d78cf29765
11 changed files with 709 additions and 214 deletions

View File

@ -4,7 +4,11 @@
#include <refcount/list.h>
#include <string.h>
int main() {
void *counting_strdup_callback(const void *str, void *ignored) {
return counting_strdup(str);
}
int main(int argc, const char **argv) {
refcount_global_allocator = &COUNTING_ALLOCATOR;
assert(refcount_list_length(NULL) == 0);
@ -77,7 +81,7 @@ int main() {
assert(strcmp(refcount_list_nth(l, 3), "str4") == 0);
assert(strcmp(refcount_list_nth(l, 4), "str5") == 0);
RefcountList *l2 = refcount_list_copy(l, (void *) counting_strdup);
RefcountList *l2 = refcount_list_copy(l, counting_strdup_callback, NULL);
refcount_list_free(l, counting_free);