From 3ef40181f1e9a47b68465bfc34835edcbfe515e0 Mon Sep 17 00:00:00 2001 From: Anton Adamansky Date: Sun, 12 Nov 2023 00:08:02 +0700 Subject: [PATCH] * Added void iwulist_reset(IWULIST *list) (iwarr.h) --- Changelog | 1 + src/utils/iwarr.c | 7 +++++++ src/utils/iwarr.h | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/Changelog b/Changelog index 09beae9..dc57462 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,6 @@ iowow (1.4.17) UNRELEASED; urgency=medium + * Added void iwulist_reset(IWULIST *list) (iwarr.h) * Added experimental jbn_from_js() (iwjson.h) * Fixed C++ compilation errors https://github.com/Softmotions/ejdb/issues/381 * Fixed Correct UCS-16 surrogate pair start code point. #51 diff --git a/src/utils/iwarr.c b/src/utils/iwarr.c index c51b322..6c3a03f 100644 --- a/src/utils/iwarr.c +++ b/src/utils/iwarr.c @@ -215,6 +215,13 @@ iwrc iwulist_clear(IWULIST *list) { return 0; } +void iwulist_reset(IWULIST *list) { + if (list) { + list->start = 0; + list->num = 0; + } +} + void iwulist_destroy_keep(IWULIST *list) { if (list) { free(list->array); diff --git a/src/utils/iwarr.h b/src/utils/iwarr.h index 855f2bf..a543438 100644 --- a/src/utils/iwarr.h +++ b/src/utils/iwarr.h @@ -103,6 +103,12 @@ IW_EXPORT IW_ALLOC IWULIST* iwulist_create(size_t initial_length, size_t unit_si */ IW_EXPORT iwrc iwulist_clear(IWULIST *list); +/** + * @brief Resets number of elements to zero. + * Underlying list array is not destroyed. + */ +IW_EXPORT void iwulist_reset(IWULIST *list); + /** * @brief Destroys and deallocates a given unit list. *