This helper function takes in a heap-allocated buffer of heap-allocated
strings. It frees empty strings and moves other strings on top of them.
---
src/service.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/service.c b/src/service.c
index 2d8245e..3cf49a8 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2926,6 +2926,23 @@ static DBusMessage *get_properties(DBusConnection *conn,
return reply;
}
+static char **remove_empty_strings(char **strv)
+{
+ int index = 0;
+ char **iter = strv;
+
+ while (*iter) {
+ if (**iter)
+ strv[index++] = *iter;
+ else
+ g_free(*iter);
+ iter++;
+ }
+
+ strv[index] = NULL;
+ return strv;
+}
+
static int update_proxy_configuration(struct connman_service *service,
DBusMessageIter *array)
{
--
2.1.0
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman