From e7a953d9ce397eeffbd99c1e9e875df2be23944b Mon Sep 17 00:00:00 2001 From: Maciej Bocianski Date: Fri, 30 Aug 2019 13:20:12 +0200 Subject: [PATCH] EventQueue: allow passing (0, NULL) on static queue creation --- events/source/EventQueue.cpp | 6 +++--- events/source/equeue.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/events/source/EventQueue.cpp b/events/source/EventQueue.cpp index 89ae0bfc0b3a..a64440e39e28 100644 --- a/events/source/EventQueue.cpp +++ b/events/source/EventQueue.cpp @@ -24,9 +24,9 @@ namespace events { EventQueue::EventQueue(unsigned event_size, unsigned char *event_pointer) { if (event_size == 0) { - // As static queue (EventQueue(0)) won't perform any access to its dummy buffer - // set 1B dummy buffer as pointer to itself - equeue_create_inplace(&_equeue, 1, this); + // As static queue (EventQueue(0)) won't perform any access to its data buffer + // we can pass (0, NULL) + equeue_create_inplace(&_equeue, 0, NULL); } else { if (!event_pointer) { equeue_create(&_equeue, event_size); diff --git a/events/source/equeue.c b/events/source/equeue.c index f73513269add..cd671afa7b28 100644 --- a/events/source/equeue.c +++ b/events/source/equeue.c @@ -22,7 +22,7 @@ #include // check if the event is allocaded by user - event address is outside queues internal buffer address range -#define EQUEUE_IS_USER_ALLOCATED_EVENT(e) (((uintptr_t)(e) < (uintptr_t)q->buffer) || ((uintptr_t)(e) > ((uintptr_t)q->slab.data))) +#define EQUEUE_IS_USER_ALLOCATED_EVENT(e) ((q->buffer == NULL) || ((uintptr_t)(e) < (uintptr_t)q->buffer) || ((uintptr_t)(e) > ((uintptr_t)q->slab.data))) // calculate the relative-difference between absolute times while // correctly handling overflow conditions