diff options
author | Thomas Haller <thaller@redhat.com> | 2019-01-09 21:58:26 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-01-15 09:52:01 +0100 |
commit | e18ff51d4f4eb073b5aa3dab1d762b5d8abbeb2f (patch) | |
tree | 49c56947f664471c07d46f1e60c03eb25aa1c4d3 | |
parent | 694533f52933841016227684b75bf113913335c1 (diff) | |
download | NetworkManager-e18ff51d4f4eb073b5aa3dab1d762b5d8abbeb2f.tar.gz |
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.
-rw-r--r-- | src/tests/test-general.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/tests/test-general.c b/src/tests/test-general.c index 2db6e60f6c..f065d12721 100644 --- a/src/tests/test-general.c +++ b/src/tests/test-general.c @@ -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); |