From 01e7cb11bfe7fa5d7166626c05bc78ae0f66a29e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 19 Apr 2019 11:40:56 +0200 Subject: 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. --- libnm-core/nm-setting-tc-config.c | 10 ++++------ libnm-core/nm-setting-tc-config.h | 2 +- 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); -- cgit v1.2.1