From d1ae1c718a063e1bb9660f94b747d9206a8bba83 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Fri, 12 Jul 2024 18:00:44 +0530 Subject: queue: use single path for memory management --- src/queue.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/queue.c b/src/queue.c index 049d62c..af96630 100644 --- a/src/queue.c +++ b/src/queue.c @@ -204,14 +204,20 @@ static int queue_push(struct queue *queue, struct job *job) void queue_thread_free(struct queue_thread *queue_thread) { - struct job *cur, *next; + struct job *j; int ret; if (queue_thread == NULL) return; - CIRCLEQ_FOREACH_FREE(cur, next, &queue_thread->queue->jobs, clist, - job_free); + while (!CIRCLEQ_EMPTY(&queue_thread->queue->jobs)) { + j = CIRCLEQ_FIRST(&queue_thread->queue->jobs); + ret = queue_dag_isolate(j, NULL, &queue_thread->queue->jobs, + queue_thread->queue->htab); + if (ret < 0) + return; + job_free(j); + } htab_free(queue_thread->queue->htab); ret = sem_destroy(&queue_thread->queue->sem); -- cgit v1.2.3