From 02c27583a539c4e8073509536d328581cf1ba346 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Sat, 27 Apr 2024 15:26:39 +0200 Subject: Kernel: Make file descriptor numbers reusable. Instead of using the "append only" list it now uses "relist" which allows for indexes to be removed. --- kernel/lib/relist.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 kernel/lib/relist.h (limited to 'kernel/lib/relist.h') diff --git a/kernel/lib/relist.h b/kernel/lib/relist.h new file mode 100644 index 0000000..96625ba --- /dev/null +++ b/kernel/lib/relist.h @@ -0,0 +1,19 @@ +#ifndef RELIST_H +#define RELIST_H +#include + +struct relist { + void **entries; + u32 bitmap_capacity; + u64 *bitmap; +}; + +void relist_init(struct relist *list); +void relist_reset(struct relist *list); +void relist_free(struct relist *list); +int relist_clone(struct relist *in, struct relist *out); +int relist_add(struct relist *list, void *value, u32 *index); +int relist_set(struct relist *list, u32 index, void *value); +int relist_get(const struct relist *list, u32 index, void **out); +int relist_remove(struct relist *list, u32 index); +#endif -- cgit v1.2.3