diff --git a/Include/Fledasty/Core/Queue.h b/Include/Fledasty/Core/Queue.h index 2b88630..9a4b16a 100644 --- a/Include/Fledasty/Core/Queue.h +++ b/Include/Fledasty/Core/Queue.h @@ -43,6 +43,8 @@ FledastyError fledasty_queue_push(FledastyQueue *current_queue, void *value); void *fledasty_queue_peek(const FledastyQueue *current_queue); void *fledasty_queue_pop(FledastyQueue *current_queue); +FledastyError fledasty_queue_clear(FledastyQueue *current_queue); + static inline bool fledasty_queue_is_empty(const FledastyQueue *current_queue) { return current_queue->size == 0; } #endif diff --git a/Src/Core/Queue.c b/Src/Core/Queue.c index 4206615..1fc4686 100644 --- a/Src/Core/Queue.c +++ b/Src/Core/Queue.c @@ -125,3 +125,12 @@ void *fledasty_queue_pop(FledastyQueue *current_queue) { return value_address; } + +FledastyError fledasty_queue_clear(FledastyQueue *current_queue) { + if (current_queue == NULL) { + return FLEDASTY_ERROR_INVALID_POINTER; + } + + current_queue->size = 0; + return FLEDASTY_ERROR_NONE; +} diff --git a/Tests/Main.c b/Tests/Main.c index fc1d82e..cb241b1 100644 --- a/Tests/Main.c +++ b/Tests/Main.c @@ -45,6 +45,7 @@ int main() { printf("Queue popped: %d\n", *popped_data); } + fledasty_queue_clear(&test_queue); if (fledasty_queue_is_empty(&test_queue)) { printf("Queue is empty\n"); }