From 6ea499ac4028357f66956a53a19dea41af93748c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 19 Apr 2019 11:40:56 +0200 Subject: [PATCH] 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. (cherry picked from commit 01e7cb11bfe7fa5d7166626c05bc78ae0f66a29e) --- 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 aa822d83d..dc2f4f649 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 002b3db16..ab99e3cc6 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);