From 2ca7352543da24cf8cc5c7c1ea20f8c2e75ca8b9 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 3 Nov 2021 11:13:53 +0100 Subject: [PATCH] map: make a helper function for freeing entries Signed-off-by: Felix Fietkau --- map.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/map.c b/map.c index 636a46b..2eacfcd 100644 --- a/map.c +++ b/map.c @@ -506,12 +506,20 @@ void qosify_map_reload(void) qosify_map_gc(); } +static void qosify_map_free_entry(struct qosify_map_entry *e) +{ + int fd = qosify_map_fds[e->data.id]; + + avl_delete(&map_data, &e->avl); + bpf_map_delete_elem(fd, &e->data.addr); + free(e); +} + void qosify_map_gc(void) { struct qosify_map_entry *e, *tmp; int32_t timeout = 0; uint32_t cur_time = qosify_gettime(); - int fd; next_timeout = 0; avl_for_each_element_safe(&map_data, e, avl, tmp) { @@ -531,10 +539,7 @@ void qosify_map_gc(void) if (e->data.file || e->data.user) continue; - avl_delete(&map_data, &e->avl); - fd = qosify_map_fds[e->data.id]; - bpf_map_delete_elem(fd, &e->data.addr); - free(e); + qosify_map_free_entry(e); } if (!timeout) -- 2.30.2