mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-03 05:28:01 +02:00
glib-aux/tests: use struct initialization in _nmtst_add_test_func_full()
It's nicer, and doesn't require g_malloc0() to ensure all fields are initialized.
This commit is contained in:
parent
eda7d08a02
commit
e4104a9f12
1 changed files with 9 additions and 6 deletions
|
|
@ -878,13 +878,16 @@ _nmtst_add_test_func_full(const char *testpath,
|
|||
g_assert(testpath && testpath[0]);
|
||||
g_assert(func_test);
|
||||
|
||||
data = g_malloc0(G_STRUCT_OFFSET(NmtstTestData, args) + (sizeof(gpointer) * (n_args + 1u)));
|
||||
data = g_malloc(G_STRUCT_OFFSET(NmtstTestData, args) + (sizeof(gpointer) * (n_args + 1u)));
|
||||
|
||||
*data = (NmtstTestData){
|
||||
._testpath = g_strdup(testpath),
|
||||
._func_test = func_test,
|
||||
._func_setup = func_setup,
|
||||
._func_teardown = func_teardown,
|
||||
.n_args = n_args,
|
||||
};
|
||||
|
||||
data->_testpath = g_strdup(testpath);
|
||||
data->_func_test = func_test;
|
||||
data->_func_setup = func_setup;
|
||||
data->_func_teardown = func_teardown;
|
||||
data->n_args = n_args;
|
||||
va_start(ap, n_args);
|
||||
for (i = 0; i < n_args; i++)
|
||||
data->args[i] = va_arg(ap, gpointer);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue