aboutsummaryrefslogtreecommitdiff
path: root/include/kpl/memory.h
diff options
context:
space:
mode:
authornodist <kevin.comas.git@gmail.com>2026-11-05 15:22:02 -0500
committernodist <kevin.comas.git@gmail.com>2026-11-05 15:22:02 -0500
commit7b9204a8680539bc4795a14f3d9a34e47981d0c3 (patch)
tree7aa69bba0c9cbee0cafb638fd49af64958dbb228 /include/kpl/memory.h
parentfaa937cb09cd01f4ea94f5d7722a20e9c1246df0 (diff)
more objects and special slab for gc
Diffstat (limited to 'include/kpl/memory.h')
-rw-r--r--include/kpl/memory.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/kpl/memory.h b/include/kpl/memory.h
index b69867a..3bb4871 100644
--- a/include/kpl/memory.h
+++ b/include/kpl/memory.h
@@ -35,8 +35,10 @@ typedef struct {
* The memory is allocated from buffer and returned to the pool
* The slabs and buffers are freed and returned to the system at once on allocator free
* The object pools are from each mapped buffer, they do not need to be freed
+ * The kpl_object_gc get their own allocator+pool because they do not align to a power of two and a lot are needed
*/
typedef struct {
+ kpl_memory_allocator_slab_group slab_gc; // all kpl_object_gc are allocated through here
kpl_memory_allocator_slab_group slabs[KPL_MEMORY_ALLOCATOR_SLAB_COUNT];
} kpl_memory_allocator;
@@ -57,6 +59,17 @@ void kpl_memory_allocator_free(kpl_memory_allocator *memory_allocator);
void *kpl_memory_allocator_allocate(kpl_memory_allocator *memory_allocator, int32_t size, uint16_t thread_id);
/*
+ * Only called though gc_new
+ * All allocations must extend KPL_OBJECT_GC_HEADER
+ */
+void *kpl_memory_allocator_allocate_gc(kpl_memory_allocator *memory_allocator, uint16_t thread_id);
+
+/*
* Only call this though kpl_env_object_return
*/
void kpl_memory_allocator_return(kpl_memory_allocator *memory_allocator, void *object);
+
+/*
+ * Only called though gc delete
+ */
+void kpl_memory_allocator_return_gc(kpl_memory_allocator *memory_allocator, void *object);