From: Felix Fietkau Date: Wed, 3 Nov 2021 10:13:53 +0000 (+0100) Subject: map: make a helper function for freeing entries X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=2ca7352543da24cf8cc5c7c1ea20f8c2e75ca8b9;p=project%2Fqosify.git map: make a helper function for freeing entries Signed-off-by: Felix Fietkau --- 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)