Skip to content

Commit 4c3889d

Browse files
EventQueue: allow passing (0, NULL) on static queue creation
1 parent b45d6d6 commit 4c3889d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

events/source/EventQueue.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ namespace events {
2424
EventQueue::EventQueue(unsigned event_size, unsigned char *event_pointer)
2525
{
2626
if (event_size == 0) {
27-
// As static queue (EventQueue(0)) won't perform any access to its dummy buffer
28-
// set 1B dummy buffer as pointer to itself
29-
equeue_create_inplace(&_equeue, 1, this);
27+
// As static queue (EventQueue(0)) won't perform any access to its data buffer
28+
// we can pass (0, NULL)
29+
equeue_create_inplace(&_equeue, 0, NULL);
3030
} else {
3131
if (!event_pointer) {
3232
equeue_create(&_equeue, event_size);

events/source/equeue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <string.h>
2323

2424
// check if the event is allocaded by user - event address is outside queues internal buffer address range
25-
#define EQUEUE_IS_USER_ALLOCATED_EVENT(e) (((uintptr_t)(e) < (uintptr_t)q->buffer) || ((uintptr_t)(e) > ((uintptr_t)q->slab.data)))
25+
#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)))
2626

2727
// calculate the relative-difference between absolute times while
2828
// correctly handling overflow conditions

0 commit comments

Comments
 (0)