aboutsummaryrefslogtreecommitdiff
path: root/broccoli
diff options
context:
space:
mode:
authorRobert Gustafsson <robg@student.chalmers.se>2017-10-02 20:07:56 +0200
committerAndreas Lindhé <andreas@lindhe.io>2017-10-09 12:14:35 +0200
commit9749f352e1f65ce96c4a307d80459f7441903388 (patch)
tree93e6e29beb7bcd3e9d5c72b93dd1eb3c93f84655 /broccoli
parentf41e21a2bbcd1bbf559212092f0f2b119e446756 (diff)
downloadmidbro-9749f352e1f65ce96c4a307d80459f7441903388.tar.gz
midbro-9749f352e1f65ce96c4a307d80459f7441903388.tar.bz2
Fix memory alloc issue in fifoqueue
Diffstat (limited to 'broccoli')
-rw-r--r--broccoli/fifoqueue.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/broccoli/fifoqueue.c b/broccoli/fifoqueue.c
index dfb8464..e8a1525 100644
--- a/broccoli/fifoqueue.c
+++ b/broccoli/fifoqueue.c
@@ -54,7 +54,7 @@ add_to_queue(Fifo_q * q, Sensor_t * sensor)
else if(is_full(q)){
return -1;
}
- Queue_t * new_elem = (Queue_t *) malloc(sizeof(Queue_t *));
+ Queue_t * new_elem = (Queue_t *) malloc(sizeof(Queue_t));
new_elem->next = NULL;
new_elem->sensor = sensor;
if(is_empty(q)){
@@ -78,7 +78,7 @@ pop_from_queue(Fifo_q * q)
}
pthread_mutex_lock(&lock);
Queue_t * head = q->head;
- q->head = q->head->next;
+ q->head = head->next;
Sensor_t * sensor = head->sensor;
free(head);
q->currentSize--;
@@ -88,7 +88,7 @@ pop_from_queue(Fifo_q * q)
Sensor_t *
create_sensor_object(int value, int uid){
- Sensor_t * sensor = (Sensor_t *) malloc(sizeof(Sensor_t *));
+ Sensor_t * sensor = (Sensor_t *) malloc(sizeof(Sensor_t));
sensor->value = value;
sensor->uid = uid;
return sensor;