From: Peter Meerwald <p.meerwald@xxxxxxxxxxxxxxxxxx> gets a pointer to the first entry's data if it exists, NULL otherwise Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net> --- src/pulsecore/queue.c | 11 +++++++++++ src/pulsecore/queue.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/src/pulsecore/queue.c b/src/pulsecore/queue.c index f4216ee..de87f33 100644 --- a/src/pulsecore/queue.c +++ b/src/pulsecore/queue.c @@ -117,6 +117,17 @@ void* pa_queue_pop(pa_queue *q) { return p; } +const void* pa_queue_peek(pa_queue *q) { + struct queue_entry *e; + + pa_assert(q); + + if (!(e = q->front)) + return NULL; + + return e->data; +} + int pa_queue_isempty(pa_queue *q) { pa_assert(q); diff --git a/src/pulsecore/queue.h b/src/pulsecore/queue.h index 1b95ec8..ebaa148 100644 --- a/src/pulsecore/queue.h +++ b/src/pulsecore/queue.h @@ -38,6 +38,9 @@ void pa_queue_free(pa_queue *q, pa_free_cb_t free_func); void pa_queue_push(pa_queue *q, void *p); void* pa_queue_pop(pa_queue *q); +/* Get a pointer to the first entry's data if it exists, NULL otherwise */ +const void* pa_queue_peek(pa_queue *q); + int pa_queue_isempty(pa_queue *q); #endif -- 1.9.1