From 1f9e5dd106300779e6e699c819a48f6165ac4c99 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Mon, 7 Oct 2013 08:38:06 -0300 Subject: [PATCH] Use a GLib main loop --- f2fchat.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/f2fchat.c b/f2fchat.c index 55bdc5a..00c774f 100644 --- a/f2fchat.c +++ b/f2fchat.c @@ -17,16 +17,24 @@ */ #include "friend.h" +#include + +static gboolean quit(gpointer data) +{ + GMainLoop *loop = data; + g_main_loop_quit(loop); + return G_SOURCE_CONTINUE; +} int main(int argc, char **argv) { struct cache *cache; - int out = 0; + GMainLoop *loop; create_cache(&cache); load_cache(cache, "friends.cache"); - while (!out) { - out = 1; - } + loop = g_main_loop_new(g_main_context_default(), TRUE); + g_idle_add(quit, loop); + g_main_loop_run(loop); store_cache(cache, "friends.cache"); destroy_cache(cache); return 0; -- 2.20.1