tests: don't use alloca() in tests

The only purpose of using alloca() to avoid the overhead of heap-allocation
and possible save a line in source code for managing/freeing the heap allocation.

For tests we don't care about performance, and (in this case)
the code does not get any shorter.

Avoid alloca() in tests, because alloca() is something to search for
when reviewing code for stack overflows. No need to have such false
positives show up in tests.
This commit is contained in:
Thomas Haller 2019-01-09 21:58:26 +01:00
parent 694533f529
commit e18ff51d4f

View file

@ -352,13 +352,13 @@ _match_connection (GSList *connections,
gint64 default_v4_metric,
gint64 default_v6_metric)
{
NMConnection **list;
gs_free NMConnection **list = NULL;
guint i, len;
len = g_slist_length (connections);
g_assert (len < 10);
list = g_alloca ((len + 1) * sizeof (NMConnection *));
list = g_malloc ((len + 1) * sizeof (NMConnection *));
for (i = 0; i < len; i++, connections = connections->next) {
g_assert (connections);
g_assert (connections->data);