From 51f92be11ee8989424281af0b1a2bc1f66e04e54 Mon Sep 17 00:00:00 2001 From: Robert Gustafsson Date: Wed, 18 Oct 2017 12:42:05 +0200 Subject: Attempt to fix memory leak Fix memory leak causing not appended values to be allocated --- broccoli/src/fifoqueue.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/broccoli/src/fifoqueue.c b/broccoli/src/fifoqueue.c index 6a99740..f3d9272 100644 --- a/broccoli/src/fifoqueue.c +++ b/broccoli/src/fifoqueue.c @@ -47,6 +47,7 @@ add_to_queue(Fifo_q * q, Sensor_t * sensor) if(q == NULL){ printf("Error: Queue not initialized\n"); + free(sensor); //free if not appended return -1; } else if(is_full(q)){ @@ -55,6 +56,7 @@ add_to_queue(Fifo_q * q, Sensor_t * sensor) pop_from_queue(q); #endif q->droppedValues++; + free(sensor); //free if not appended return 0; } sem_wait(&q->lock); -- cgit v1.2.3