[kdbus] Add SipHash algorithm
[platform/upstream/glib.git] / tests / mainloop-test.c
index 4bcb05f..5d30550 100644 (file)
@@ -54,7 +54,7 @@ struct _TestData
 
 static void cleanup_crawlers (GMainContext *context);
 
-gboolean
+static gboolean
 read_all (GIOChannel *channel, char *buf, gsize len)
 {
   gsize bytes_read = 0;
@@ -78,7 +78,7 @@ read_all (GIOChannel *channel, char *buf, gsize len)
   return TRUE;
 }
 
-gboolean
+static gboolean
 write_all (GIOChannel *channel, char *buf, gsize len)
 {
   gsize bytes_written = 0;
@@ -97,7 +97,7 @@ write_all (GIOChannel *channel, char *buf, gsize len)
   return TRUE;
 }
 
-gboolean
+static gboolean
 adder_callback (GIOChannel   *source,
                GIOCondition  condition,
                gpointer      data)
@@ -105,7 +105,7 @@ adder_callback (GIOChannel   *source,
   char buf1[32];
   char buf2[32];
 
-  char result[32];
+  char result[32] = { 0, };
 
   AddrData *addr_data = data;
 
@@ -122,7 +122,7 @@ adder_callback (GIOChannel   *source,
   return TRUE;
 }
 
-gboolean
+static gboolean
 timeout_callback (gpointer data)
 {
   AddrData *addr_data = data;
@@ -132,7 +132,7 @@ timeout_callback (gpointer data)
   return TRUE;
 }
 
-gpointer
+static gpointer
 adder_thread (gpointer data)
 {
   GMainContext *context;
@@ -190,11 +190,12 @@ adder_thread (gpointer data)
   g_mutex_unlock (&context_array_mutex);
 
   cleanup_crawlers (context);
+  g_main_context_unref (context);
 
   return NULL;
 }
 
-void
+static void
 io_pipe (GIOChannel **channels)
 {
   gint fds[2];
@@ -212,11 +213,11 @@ io_pipe (GIOChannel **channels)
   g_io_channel_set_close_on_unref (channels[1], TRUE);
 }
 
-void
+static void
 do_add (GIOChannel *in, gint a, gint b)
 {
-  char buf1[32];
-  char buf2[32];
+  char buf1[32] = { 0, };
+  char buf2[32] = { 0, };
 
   sprintf (buf1, "%d", a);
   sprintf (buf2, "%d", b);
@@ -225,7 +226,7 @@ do_add (GIOChannel *in, gint a, gint b)
   write_all (in, buf2, 32);
 }
 
-gboolean
+static gboolean
 adder_response (GIOChannel   *source,
                GIOCondition  condition,
                gpointer      data)
@@ -261,7 +262,7 @@ adder_response (GIOChannel   *source,
   return TRUE;
 }
 
-void
+static void
 create_adder_thread (void)
 {
   GError *err = NULL;
@@ -398,14 +399,12 @@ recurser_start (gpointer data)
   return TRUE;
 }
 
-int 
+int
 main (int   argc,
       char *argv[])
 {
   gint i;
 
-  g_thread_init (NULL);
-
   context_array = g_ptr_array_new ();
 
   crawler_array = g_ptr_array_new ();
@@ -432,5 +431,8 @@ main (int   argc,
   g_main_loop_run (main_loop);
   g_main_loop_unref (main_loop);
 
+  g_ptr_array_unref (crawler_array);
+  g_ptr_array_unref (context_array);
+
   return 0;
 }