aboutsummaryrefslogtreecommitdiff
path: root/src/queue.c
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-06-16 13:17:35 +0530
committersinanmohd <sinan@sinanmohd.com>2024-06-16 13:20:24 +0530
commitd136b3c1b70d7ae687b763c59d1bc03d4ad3dbc2 (patch)
treecda33c21907a219fe18032f92b0bb8fedaf0c4d2 /src/queue.c
parentf407bbb1b00194fdc89ca382f4cf2f1f536ab18e (diff)
c: improve memory management
Diffstat (limited to 'src/queue.c')
-rw-r--r--src/queue.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/queue.c b/src/queue.c
index e1e41ec..191c3f8 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -65,16 +65,14 @@ static void queue_push(struct queue *queue, struct job *job)
void queue_thread_free(struct queue_thread *queue_thread)
{
- struct job *job;
+ struct job *cur, *next;
int ret;
if (queue_thread == NULL)
return;
- CIRCLEQ_FOREACH (job, &queue_thread->queue->jobs, clist) {
- CIRCLEQ_REMOVE(&queue_thread->queue->jobs, job, clist);
- free(job);
- }
+ CIRCLEQ_FOREACH_FREE(cur, next, &queue_thread->queue->jobs, clist,
+ job_free);
ret = sem_destroy(&queue_thread->queue->sem);
if (ret < 0)
@@ -85,6 +83,7 @@ void queue_thread_free(struct queue_thread *queue_thread)
free(queue_thread->queue);
fclose(queue_thread->stream);
+ free(queue_thread);
}
int queue_thread_new(struct queue_thread **queue_thread, FILE *stream)