Skip to content

Commit

Permalink
queue: use single path for memory management
Browse files Browse the repository at this point in the history
  • Loading branch information
sinanmohd committed Jul 12, 2024
1 parent 371b005 commit d1ae1c7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d1ae1c7

Please sign in to comment.