summaryrefslogtreecommitdiff
path: root/broccoli
diff options
context:
space:
mode:
authorRobert Gustafsson <robg@student.chalmers.se>2017-10-02 20:07:56 +0200
committerRobert Gustafsson <robg@student.chalmers.se>2017-10-02 20:07:56 +0200
commitf2fd66ebf34e010770dca687f1a0a817b8fa4212 (patch)
treea3b80aa6faf0a160a5cd213e480d25a245dc4201 /broccoli
parenta1f91d62c35604c8d5498cc15c1b4d98cd712ec7 (diff)
downloadmidbro-f2fd66ebf34e010770dca687f1a0a817b8fa4212.tar.gz
midbro-f2fd66ebf34e010770dca687f1a0a817b8fa4212.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;