aboutsummaryrefslogtreecommitdiff
path: root/include/kpl/allocate.h
diff options
context:
space:
mode:
authornodist <kevin.comas.git@gmail.com>2026-11-01 10:07:03 -0500
committernodist <kevin.comas.git@gmail.com>2026-11-01 10:07:03 -0500
commit9a61168aec3373be702bdbf252043ce3605f2b5b (patch)
tree49078373733f1eb4294569cede513aa7f82b94f0 /include/kpl/allocate.h
parentfcc5294b919856ff04fef859760d48d0da136396 (diff)
add basic gc test
Diffstat (limited to 'include/kpl/allocate.h')
-rw-r--r--include/kpl/allocate.h38
1 files changed, 0 insertions, 38 deletions
diff --git a/include/kpl/allocate.h b/include/kpl/allocate.h
deleted file mode 100644
index 3da4a10..0000000
--- a/include/kpl/allocate.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * KPL object allocators helpers
- */
-
-#pragma once
-
-/*
- * All allocations must extend the KPL_OBJECT_HEADER
- * All objects are allocated through this
- */
-inline void *kpl_object_allocate(kpl_thread *thread, int32_t size) {
- kpl_object *obj = kpl_memory_allocator_allocate(&thread->memory_allocator, size, thread->thread_id);
- if (!obj)
- return NULL;
- obj->object_flags = KPL_OBJECT_FLAGS_EMPTY;
- __atomic_clear(&obj->gc_mark, __ATOMIC_RELAXED);
- obj->gc_prev = obj->gc_next = NULL;
- obj->gc_next = thread->gc_head;
- if (thread->gc_head)
- thread->gc_head->gc_prev = obj;
- thread->gc_head = obj;
- thread->gc_cycle_change++;
- return obj;
-}
-
-/*
- * All objects are returned by this
- */
-inline void kpl_object_return(kpl_env *env, void *object) {
- kpl_object *obj = object;
- if (obj->gc_prev)
- obj->gc_prev->gc_next = obj->gc_next;
- if (obj->gc_next)
- obj->gc_next->gc_prev = obj->gc_prev;
- kpl_thread *thread = &env->threads[obj->thread_id];
- kpl_memory_allocator_return(&thread->memory_allocator, object);
- thread->gc_cycle_change--;
-}