summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-04-19 11:40:56 +0200
committerThomas Haller <thaller@redhat.com>2019-04-20 08:09:52 +0200
commit01e7cb11bfe7fa5d7166626c05bc78ae0f66a29e (patch)
tree5831708249d8021ad1322a2689b3f46d2ad8eb25
parent48316f987a55474fc6db53c0354961f79ae475cf (diff)
downloadNetworkManager-01e7cb11bfe7fa5d7166626c05bc78ae0f66a29e.tar.gz
libnm: don't return deep-copied strv array from nm_tc_qdisc_get_attribute_names()
Most of the caller won't require a deep-clone of the attribute names. Likely, the fetch the name, so they can lookup the attributes. In that common case, there is no need to clone the strings themself.
-rw-r--r--libnm-core/nm-setting-tc-config.c10
-rw-r--r--libnm-core/nm-setting-tc-config.h2
2 files changed, 5 insertions, 7 deletions
diff --git a/libnm-core/nm-setting-tc-config.c b/libnm-core/nm-setting-tc-config.c
index aa822d83d1..dc2f4f6498 100644
--- a/libnm-core/nm-setting-tc-config.c
+++ b/libnm-core/nm-setting-tc-config.c
@@ -327,19 +327,17 @@ nm_tc_qdisc_get_parent (NMTCQdisc *qdisc)
*
* Gets an array of attribute names defined on @qdisc.
*
- * Returns: (transfer full): a %NULL-terminated array of attribute names,
+ * Returns: (transfer container): a %NULL-terminated array of attribute names
+ * or %NULL if no attributes are set.
*
* Since: 1.18
**/
-char **
+const char **
nm_tc_qdisc_get_attribute_names (NMTCQdisc *qdisc)
{
- const char **names;
-
g_return_val_if_fail (qdisc, NULL);
- names = nm_utils_strdict_get_keys (qdisc->attributes, TRUE, NULL);
- return nm_utils_strv_make_deep_copied_nonnull (names);
+ return nm_utils_strdict_get_keys (qdisc->attributes, TRUE, NULL);
}
GHashTable *
diff --git a/libnm-core/nm-setting-tc-config.h b/libnm-core/nm-setting-tc-config.h
index 002b3db161..ab99e3cc6d 100644
--- a/libnm-core/nm-setting-tc-config.h
+++ b/libnm-core/nm-setting-tc-config.h
@@ -60,7 +60,7 @@ NM_AVAILABLE_IN_1_12
guint32 nm_tc_qdisc_get_parent (NMTCQdisc *qdisc);
NM_AVAILABLE_IN_1_18
-char**nm_tc_qdisc_get_attribute_names (NMTCQdisc *qdisc);
+const char **nm_tc_qdisc_get_attribute_names (NMTCQdisc *qdisc);
NM_AVAILABLE_IN_1_18
GVariant *nm_tc_qdisc_get_attribute (NMTCQdisc *qdisc,
const char *name);