From 7b9204a8680539bc4795a14f3d9a34e47981d0c3 Mon Sep 17 00:00:00 2001 From: nodist Date: Thu, 5 Nov 2026 15:22:02 -0500 Subject: more objects and special slab for gc --- include/kpl/memory.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/kpl/memory.h') 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; @@ -56,7 +58,18 @@ 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); -- cgit v1.2.3