summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-11-06 16:29:41 +0100
committerThomas Haller <thaller@redhat.com>2020-11-09 17:25:24 +0100
commit571aeec933ac8bd62ee4888948bea4361316dd8b (patch)
tree31f884885d1ea7325df3dcd65a0814640d26ce9e
parentc4d981959eac8c3beeecba8e8436ebda707f553c (diff)
downloadNetworkManager-571aeec933ac8bd62ee4888948bea4361316dd8b.tar.gz
shared: add nm_utils_named_value_clear_with_g_free() helper
-rw-r--r--shared/nm-glib-aux/nm-shared-utils.c12
-rw-r--r--shared/nm-glib-aux/nm-shared-utils.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c
index 7f766871f6..b1a557a28e 100644
--- a/shared/nm-glib-aux/nm-shared-utils.c
+++ b/shared/nm-glib-aux/nm-shared-utils.c
@@ -3066,6 +3066,18 @@ nm_utils_fd_read_loop_exact(int fd, void *buf, size_t nbytes, bool do_poll)
/*****************************************************************************/
+void
+nm_utils_named_value_clear_with_g_free(NMUtilsNamedValue *val)
+{
+ if (val) {
+ gs_free gpointer x_name = NULL;
+ gs_free gpointer x_value = NULL;
+
+ x_name = (gpointer) g_steal_pointer(&val->name);
+ x_value = g_steal_pointer(&val->value_ptr);
+ }
+}
+
G_STATIC_ASSERT(G_STRUCT_OFFSET(NMUtilsNamedValue, name) == 0);
NMUtilsNamedValue *
diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h
index 1e2c482549..df3f55195c 100644
--- a/shared/nm-glib-aux/nm-shared-utils.h
+++ b/shared/nm-glib-aux/nm-shared-utils.h
@@ -1460,6 +1460,8 @@ void nm_utils_named_value_list_sort(NMUtilsNamedValue *arr,
GCompareDataFunc compare_func,
gpointer user_data);
+void nm_utils_named_value_clear_with_g_free(NMUtilsNamedValue *val);
+
/*****************************************************************************/
gpointer *nm_utils_hash_keys_to_array(GHashTable * hash,