From abf9cf5bec2712465400417cc8232fee2d1cce28 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Tue, 11 Jun 2024 13:33:01 +0200 Subject: TCP stuff --- kernel/lib/relist.c | 7 +++++++ kernel/lib/relist.h | 1 + 2 files changed, 8 insertions(+) (limited to 'kernel/lib') diff --git a/kernel/lib/relist.c b/kernel/lib/relist.c index 01af884..2e45429 100644 --- a/kernel/lib/relist.c +++ b/kernel/lib/relist.c @@ -5,6 +5,7 @@ #include void relist_init(struct relist *list) { + list->num_entries = 0; list->bitmap_capacity = 1; list->bitmap = kcalloc(sizeof(u64), list->bitmap_capacity); if (!list->bitmap) { @@ -28,6 +29,7 @@ relist_init_error: } void relist_reset(struct relist *list) { + list->num_entries = 0; memset(list->bitmap, 0, list->bitmap_capacity * sizeof(u64)); } @@ -43,12 +45,14 @@ int relist_clone(struct relist *in, struct relist *out) { kfree(out->bitmap); goto relist_clone_error; } + out->num_entries = in->num_entries; memcpy(out->bitmap, in->bitmap, sizeof(u64) * out->bitmap_capacity); memcpy(out->entries, in->entries, sizeof(void *) * sizeof(u64) * 8 * out->bitmap_capacity); return 1; relist_clone_error: + out->num_entries = 0; out->bitmap_capacity = 0; out->entries = NULL; out->bitmap = NULL; @@ -100,6 +104,7 @@ int relist_add(struct relist *list, void *value, u32 *index) { if (index) { *index = entry; } + list->num_entries++; list->bitmap[entry / 64] |= ((u64)1 << (entry % 64)); return 1; } @@ -114,6 +119,7 @@ int relist_remove(struct relist *list, u32 index) { assert(0); return 0; } + list->num_entries--; list->bitmap[index / 64] &= ~((u64)1 << (index % 64)); return 1; } @@ -148,6 +154,7 @@ int relist_get(const struct relist *list, u32 index, void **out, int *end) { } void relist_free(struct relist *list) { + list->num_entries = 0; list->bitmap_capacity = 0; kfree(list->entries); kfree(list->bitmap); diff --git a/kernel/lib/relist.h b/kernel/lib/relist.h index 734e5dc..409032d 100644 --- a/kernel/lib/relist.h +++ b/kernel/lib/relist.h @@ -5,6 +5,7 @@ struct relist { void **entries; u32 bitmap_capacity; + u32 num_entries; u64 *bitmap; }; -- cgit v1.2.3