mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 08:20:28 +01:00
all: use nm_strv_empty_new() helper
This commit is contained in:
parent
cb5ef4b3a0
commit
503a76f604
9 changed files with 11 additions and 11 deletions
|
|
@ -103,7 +103,7 @@ nm_vpn_editor_plugin_get_service_add_details(NMVpnEditorPlugin *plugin, const ch
|
|||
if (vt.fcn_get_service_add_details)
|
||||
details = vt.fcn_get_service_add_details(plugin, service_name);
|
||||
if (!details)
|
||||
return g_new0(char *, 1);
|
||||
return nm_strv_empty_new();
|
||||
return details;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ next:
|
|||
if (arr && arr->len > 0)
|
||||
nameservers_new = nm_strv_dup((char **) arr->pdata, arr->len, FALSE);
|
||||
else
|
||||
nameservers_new = g_new0(char *, 1);
|
||||
nameservers_new = nm_strv_empty_new();
|
||||
}
|
||||
nm_assert(nameservers_new);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -728,7 +728,7 @@ nm_vpn_plugin_info_list_get_service_types(GSList *list,
|
|||
|
||||
if (l->len <= 0) {
|
||||
g_ptr_array_free(l, TRUE);
|
||||
return g_new0(char *, 1);
|
||||
return nm_strv_empty_new();
|
||||
}
|
||||
|
||||
/* sort the result and remove duplicates. */
|
||||
|
|
|
|||
|
|
@ -1937,7 +1937,7 @@ nm_utils_strsplit_quoted(const char *str)
|
|||
}
|
||||
|
||||
if (!arr)
|
||||
return g_new0(char *, 1);
|
||||
return nm_strv_empty_new();
|
||||
|
||||
/* We want to return an optimally sized strv array, with no excess
|
||||
* memory allocated. Hence, clone once more. */
|
||||
|
|
|
|||
|
|
@ -1860,7 +1860,7 @@ char **nm_strv_make_deep_copied_n(const char **strv, gsize len);
|
|||
static inline char **
|
||||
nm_strv_make_deep_copied_nonnull(const char **strv)
|
||||
{
|
||||
return nm_strv_make_deep_copied(strv) ?: g_new0(char *, 1);
|
||||
return nm_strv_make_deep_copied(strv) ?: nm_strv_empty_new();
|
||||
}
|
||||
|
||||
char **_nm_strv_dup(const char *const *strv, gssize len, gboolean deep_copied);
|
||||
|
|
@ -3110,7 +3110,7 @@ nm_strvarray_get_strv_full_dup(const GArray *arr,
|
|||
{
|
||||
if (!arr) {
|
||||
NM_SET_OUT(length, 0);
|
||||
return not_null ? g_new0(char *, 1) : NULL;
|
||||
return not_null ? nm_strv_empty_new() : NULL;
|
||||
}
|
||||
|
||||
nm_assert(sizeof(char *) == g_array_get_element_size((GArray *) arr));
|
||||
|
|
@ -3119,7 +3119,7 @@ nm_strvarray_get_strv_full_dup(const GArray *arr,
|
|||
|
||||
if (arr->len == 0) {
|
||||
if (preserve_empty || not_null)
|
||||
return g_new0(char *, 1);
|
||||
return nm_strv_empty_new();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1228,7 +1228,7 @@ nmtst_rand_perm_strv(const char *const *strv)
|
|||
/* this returns a (scrambled) SHALLOW copy of the strv array! */
|
||||
|
||||
n = NM_PTRARRAY_LEN(strv);
|
||||
res = (const char **) (nm_strv_dup(strv, n, FALSE) ?: g_new0(char *, 1));
|
||||
res = (const char **) (nm_strv_dup(strv, n, FALSE) ?: nm_strv_empty_new());
|
||||
nmtst_rand_perm(NULL, res, res, sizeof(char *), n);
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ _strv_cmp_fuzz_input(const char *const *in,
|
|||
if (l < 0)
|
||||
ss = g_strdupv((char **) in);
|
||||
else if (l == 0) {
|
||||
ss = nmtst_get_rand_bool() ? NULL : g_new0(char *, 1);
|
||||
ss = nmtst_get_rand_bool() ? NULL : nm_strv_empty_new();
|
||||
} else {
|
||||
ss = nm_memdup(in, sizeof(const char *) * l);
|
||||
for (i = 0; i < (gsize) l; i++)
|
||||
|
|
|
|||
|
|
@ -497,7 +497,7 @@ nmc_string_to_arg_array(const char *line,
|
|||
|
||||
arr0 = nm_strsplit_set(line ?: "", delim ?: " \t");
|
||||
if (!arr0)
|
||||
arr = g_new0(char *, 1);
|
||||
arr = nm_strv_empty_new();
|
||||
else
|
||||
arr = g_strdupv((char **) arr0);
|
||||
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ nmt_address_list_set_property(GObject *object,
|
|||
g_strfreev(priv->strings);
|
||||
priv->strings = g_value_dup_boxed(value);
|
||||
if (!priv->strings)
|
||||
priv->strings = g_new0(char *, 1);
|
||||
priv->strings = nm_strv_empty_new();
|
||||
nmt_widget_list_set_length(NMT_WIDGET_LIST(object), g_strv_length(priv->strings));
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue