From d48452faf3a076176c69df8a418957141ec66bec Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 18 Feb 2026 11:14:36 +0100 Subject: [PATCH] [winpr,utils] Add Queue_Capacity --- winpr/include/winpr/collections.h | 8 ++++++++ winpr/libwinpr/utils/collections/Queue.c | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/winpr/include/winpr/collections.h b/winpr/include/winpr/collections.h index 3fc942f37..d74ab638f 100644 --- a/winpr/include/winpr/collections.h +++ b/winpr/include/winpr/collections.h @@ -93,6 +93,14 @@ extern "C" */ WINPR_API size_t Queue_Count(wQueue* queue); + /** @brief Return the allocated elements in the queue + * + * @param queue A pointer to a queue, must not be \b NULL + * + * @return the number of objects allocated + */ + WINPR_API size_t Queue_Capacity(wQueue* queue); + /** @brief Mutex-Lock a queue * * @param queue A pointer to a queue, must not be \b NULL diff --git a/winpr/libwinpr/utils/collections/Queue.c b/winpr/libwinpr/utils/collections/Queue.c index cad43f860..61ba477d7 100644 --- a/winpr/libwinpr/utils/collections/Queue.c +++ b/winpr/libwinpr/utils/collections/Queue.c @@ -81,6 +81,19 @@ size_t Queue_Count(wQueue* queue) return ret; } +size_t Queue_Capacity(wQueue* queue) +{ + WINPR_ASSERT(queue); + + Queue_Lock(queue); + + const size_t ret = queue->capacity; + + Queue_Unlock(queue); + + return ret; +} + /** * Lock access to the ArrayList */