mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-30 13:10:11 +01:00
glib-aux/tests: use C99 flexible array members for pointers in NmtstTestData
It's just nicer code. The previous code was correct, in particular, the alignment of the data was most likely correct. Still, this is nicer.
This commit is contained in:
parent
6850766679
commit
eda7d08a02
1 changed files with 2 additions and 3 deletions
|
|
@ -783,10 +783,10 @@ struct _NmtstTestData {
|
|||
char *_testpath;
|
||||
};
|
||||
gsize n_args;
|
||||
gpointer *args;
|
||||
NmtstTestHandler _func_setup;
|
||||
GTestDataFunc _func_test;
|
||||
NmtstTestHandler _func_teardown;
|
||||
gpointer args[];
|
||||
};
|
||||
|
||||
static inline void
|
||||
|
|
@ -878,14 +878,13 @@ _nmtst_add_test_func_full(const char *testpath,
|
|||
g_assert(testpath && testpath[0]);
|
||||
g_assert(func_test);
|
||||
|
||||
data = g_malloc0(sizeof(NmtstTestData) + (sizeof(gpointer) * (n_args + 1)));
|
||||
data = g_malloc0(G_STRUCT_OFFSET(NmtstTestData, args) + (sizeof(gpointer) * (n_args + 1u)));
|
||||
|
||||
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;
|
||||
data->args = (gpointer) &data[1];
|
||||
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