mirror of
https://github.com/tailix/libshmemq.git
synced 2025-02-17 15:45:41 -05:00
Return NULL frame from pop start on empty queue
This commit is contained in:
parent
f9e5e866ec
commit
86a56387b7
2 changed files with 9 additions and 0 deletions
|
@ -196,6 +196,11 @@ void shmemq_push_end(
|
|||
|
||||
ShmemqFrame shmemq_pop_start(const Shmemq shmemq)
|
||||
{
|
||||
if (
|
||||
shmemq->buffer->header.read_frame_index ==
|
||||
shmemq->buffer->header.write_frame_index
|
||||
) return NULL;
|
||||
|
||||
return &shmemq->buffer->frames[shmemq->buffer->header.read_frame_index];
|
||||
}
|
||||
|
||||
|
|
|
@ -159,6 +159,10 @@ int main()
|
|||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
assert(producer_shmemq->buffer->header.read_frame_index == 4);
|
||||
|
||||
assert(shmemq_pop_start(&consumer_shmemq) == NULL);
|
||||
shmemq_pop_end(&consumer_shmemq, &error);
|
||||
assert(error == SHMEMQ_ERROR_BUG_POP_END_ON_EMPTY_QUEUE);
|
||||
|
||||
shmemq_finish(&consumer_shmemq, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue