summaryrefslogtreecommitdiff
path: root/src/std
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-27 14:01:16 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-27 14:01:16 +1000
commitaa0fe8457cfff9c47c0c9fa4a1c86a79c7cbf9c5 (patch)
treea7fa374cb59c6c59e386086dcdae8a7efc372b5f /src/std
parent2e2c57a8c04575eec164279a49947cfdba250853 (diff)
add a pool insert function. move RenderEnt to use handles
Diffstat (limited to 'src/std')
-rw-r--r--src/std/mem.c7
-rw-r--r--src/std/mem.h7
2 files changed, 13 insertions, 1 deletions
diff --git a/src/std/mem.c b/src/std/mem.c
index 4a4454a..a537330 100644
--- a/src/std/mem.c
+++ b/src/std/mem.c
@@ -126,3 +126,10 @@ void void_pool_dealloc(void_pool* pool, u32 raw_handle) {
pool->count--;
}
+
+u32 void_pool_insert(void_pool* pool, void* item) {
+ u32 raw_handle;
+ void* item_dest = void_pool_alloc(pool, &raw_handle);
+ memcpy(item_dest, item, pool->entry_size);
+ return raw_handle;
+} \ No newline at end of file
diff --git a/src/std/mem.h b/src/std/mem.h
index c9346cc..56c1230 100644
--- a/src/std/mem.h
+++ b/src/std/mem.h
@@ -66,6 +66,7 @@ bool void_pool_is_full(void_pool* pool);
void* void_pool_get(void_pool* pool, u32 raw_handle);
void* void_pool_alloc(void_pool* pool, u32* out_raw_handle);
void void_pool_dealloc(void_pool* pool, u32 raw_handle);
+u32 void_pool_insert(void_pool* pool, void* item);
// TODO: fn to dealloc from the pointer that was handed out
// TODO: macro that lets us specialise
@@ -88,4 +89,8 @@ void void_pool_dealloc(void_pool* pool, u32 raw_handle);
} \
static inline void Name##_pool_dealloc(Name##_pool* pool, Name##Handle handle) { \
void_pool_dealloc(&pool->inner, handle.raw); \
- }\
+ } \
+ static Name##Handle Name##_pool_insert(Name##_pool* pool, T* item) { \
+ u32 raw_handle = void_pool_insert(pool, item); \
+ return (Name##Handle){ .raw = raw_handle }; \
+ }