summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-14 13:28:12 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-14 13:28:12 +0200
commitb9a3368e7f91857c24e48933d027b3285a28f98f (patch)
tree048f1f33767ba54881e9c476f0ba199d7ff21850
parentc56a4ed3b865b4b240c6f01809c935b7b86d160b (diff)
parentaff55f153ddb247357f59b3740477e90eba527bd (diff)
downloadouroboros-b9a3368e7f91857c24e48933d027b3285a28f98f.tar.gz
ouroboros-b9a3368e7f91857c24e48933d027b3285a28f98f.zip
Merge branch 'be' of bitbucket.org:ouroboros-rina/ouroboros into be-rw_lock
-rw-r--r--src/lib/shm_ap_rbuff.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/lib/shm_ap_rbuff.c b/src/lib/shm_ap_rbuff.c
index 6c977cbb..6c04ccc5 100644
--- a/src/lib/shm_ap_rbuff.c
+++ b/src/lib/shm_ap_rbuff.c
@@ -245,18 +245,17 @@ struct rb_entry * shm_ap_rbuff_read(struct shm_ap_rbuff * rb)
if (rb == NULL)
return NULL;
- e = malloc(sizeof(*e));
- if (e == NULL)
- return NULL;
-
pthread_mutex_lock(rb->shm_mutex);
if (shm_rbuff_used(rb) == 0) {
pthread_mutex_unlock(rb->shm_mutex);
- free(e);
return NULL;
}
+ e = malloc(sizeof(*e));
+ if (e == NULL)
+ return NULL;
+
*e = *(rb->shm_base + *rb->ptr_tail);
*rb->ptr_tail = (*rb->ptr_tail + 1) & (SHM_RBUFF_SIZE -1);