mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 05:10:17 +01:00
shared: avoid heap allocation in _nm_utils_enum_from_str_full()
In the vast majority of cases is the string for _nm_utils_enum_from_str_full() short. As we duplicate it for stripping, prefer to clone it on the stack with nm_strdup_maybe_a().
This commit is contained in:
parent
e884ef39ed
commit
88a7ec8b14
1 changed files with 1 additions and 2 deletions
|
|
@ -212,8 +212,7 @@ _nm_utils_enum_from_str_full(GType type,
|
|||
|
||||
_ASSERT_enum_values_info(type, value_infos);
|
||||
|
||||
str_clone = strdup(str);
|
||||
s = nm_str_skip_leading_spaces(str_clone);
|
||||
s = nm_strdup_maybe_a(300, nm_str_skip_leading_spaces(str), &str_clone);
|
||||
g_strchomp(s);
|
||||
|
||||
klass = g_type_class_ref(type);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue