Skip to content

Commit

Permalink
EventQueue: allow passing (0, NULL) on static queue creation
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejbocianski committed Aug 30, 2019
1 parent b45d6d6 commit 4c3889d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions events/source/EventQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion events/source/equeue.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <string.h>

// 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
Expand Down

0 comments on commit 4c3889d

Please sign in to comment.