From 76f93c4fdf1af32c0eb72b1ec2250ae53a5dd220 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Debian Linux)" <rob@synchro.net>
Date: Thu, 21 Nov 2024 12:09:35 -0800
Subject: [PATCH] Add strListFastDeleteAll()

To quickly free and remove all list entries (without realloc).
---
 src/xpdev/str_list.c | 9 +++++++++
 src/xpdev/str_list.h | 1 +
 2 files changed, 10 insertions(+)

diff --git a/src/xpdev/str_list.c b/src/xpdev/str_list.c
index d28aa297ea..87f2539c3e 100644
--- a/src/xpdev/str_list.c
+++ b/src/xpdev/str_list.c
@@ -197,6 +197,15 @@ bool strListFastDelete(str_list_t list, size_t index, size_t count)
 	return strListFastRemove(list, index, count);
 }
 
+void strListFastDeleteAll(str_list_t list)
+{
+	size_t i;
+
+	for(i = 0; list[i] != NULL; ++i)
+		free(list[i]);
+	list[0] = NULL;
+}
+
 char* strListReplace(const str_list_t list, size_t index, const char* str)
 {
 	char*	buf;
diff --git a/src/xpdev/str_list.h b/src/xpdev/str_list.h
index f601cc8245..668c1e2c24 100644
--- a/src/xpdev/str_list.h
+++ b/src/xpdev/str_list.h
@@ -78,6 +78,7 @@ DLLEXPORT bool			strListFastRemove(str_list_t, size_t index, size_t count);
 /* Remove and free a string at a specific index */
 DLLEXPORT bool			strListDelete(str_list_t*, size_t index);
 DLLEXPORT bool			strListFastDelete(str_list_t, size_t index, size_t count);
+DLLEXPORT void			strListFastDeleteAll(str_list_t);
 
 /* Replace a string at a specific index */
 DLLEXPORT char*			strListReplace(const str_list_t, size_t index, const char* str);
-- 
GitLab