From 44b332d4495151a5b9fd0603b4a68874c652318e Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 24 Sep 2014 14:42:19 +0100 Subject: [PATCH] tests: Move a closure from the heap to the stack There is no need for this to be heap-allocated. --- tests/test-io-stream-cancelling.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/tests/test-io-stream-cancelling.c b/tests/test-io-stream-cancelling.c index 05cbaa0c..b43c0fd6 100644 --- a/tests/test-io-stream-cancelling.c +++ b/tests/test-io-stream-cancelling.c @@ -98,7 +98,7 @@ read_thread_cb (GInputStream *input_stream, TestIOStreamThreadData *data) int main (void) { GThread *l_cancellation_thread, *r_cancellation_thread; - CancellationData *l_data, *r_data; + CancellationData l_data, r_data; const TestIOStreamCallbacks callbacks = { read_thread_cb, @@ -114,29 +114,25 @@ int main (void) g_type_init (); g_thread_init (NULL); - l_data = g_malloc0 (sizeof (CancellationData)); - l_data->cancellable = g_cancellable_new (); - l_data->blocking = FALSE; + l_data.cancellable = g_cancellable_new (); + l_data.blocking = FALSE; - r_data = g_malloc0 (sizeof (CancellationData)); - r_data->cancellable = g_cancellable_new (); - r_data->blocking = FALSE; + r_data.cancellable = g_cancellable_new (); + r_data.blocking = FALSE; l_cancellation_thread = spawn_thread ("libnice L cancel", - cancellation_thread_cb, l_data); + cancellation_thread_cb, &l_data); r_cancellation_thread = spawn_thread ("libnice R cancel", - cancellation_thread_cb, r_data); + cancellation_thread_cb, &r_data); - run_io_stream_test (30, TRUE, &callbacks, l_data, NULL, r_data, NULL); + run_io_stream_test (30, TRUE, &callbacks, &l_data, NULL, &r_data, NULL); g_thread_join (l_cancellation_thread); g_thread_join (r_cancellation_thread); /* Free things. */ - g_object_unref (r_data->cancellable); - g_free (r_data); - g_object_unref (l_data->cancellable); - g_free (l_data); + g_object_unref (r_data.cancellable); + g_object_unref (l_data.cancellable); #ifdef G_OS_WIN32 WSACleanup (); -- GitLab