X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fchimara-glk.c;h=9d4f443d4f1e4c9f6925f25d1dc3dbee02ac9a43;hb=b4d0cc30b6c603148c7f74d23d5afde542e57f79;hp=0683572628ef4210e2cb31ccaa83096d3b030e28;hpb=d9646c0bf915d1ee5d9d3601a273ff20214bfae7;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/chimara-glk.c b/libchimara/chimara-glk.c index 0683572..9d4f443 100644 --- a/libchimara/chimara-glk.c +++ b/libchimara/chimara-glk.c @@ -158,46 +158,24 @@ chimara_glk_init(ChimaraGlk *self) priv->self = self; priv->interactive = TRUE; - priv->protect = FALSE; priv->styles = g_new0(StyleSet,1); priv->glk_styles = g_new0(StyleSet,1); priv->final_message = g_strdup("[ The game has finished ]"); - priv->running = FALSE; - priv->program = NULL; - priv->thread = NULL; priv->event_queue = g_queue_new(); priv->event_lock = g_mutex_new(); priv->event_queue_not_empty = g_cond_new(); priv->event_queue_not_full = g_cond_new(); priv->abort_lock = g_mutex_new(); - priv->abort_signalled = FALSE; priv->shutdown_lock = g_mutex_new(); priv->shutdown_key_pressed = g_cond_new(); priv->arrange_lock = g_mutex_new(); priv->rearranged = g_cond_new(); - priv->needs_rearrange = FALSE; - priv->ignore_next_arrange_event = FALSE; priv->char_input_queue = g_async_queue_new(); priv->line_input_queue = g_async_queue_new(); /* FIXME Should be g_async_queue_new_full(g_free); but only in GTK >= 2.16 */ - priv->resource_map = NULL; priv->resource_lock = g_mutex_new(); priv->resource_loaded = g_cond_new(); priv->resource_info_available = g_cond_new(); - priv->resource_load_callback = NULL; - priv->resource_load_callback_data = NULL; - priv->image_cache = NULL; - priv->program_name = NULL; - priv->program_info = NULL; - priv->story_name = NULL; - priv->interrupt_handler = NULL; - priv->root_window = NULL; - priv->fileref_list = NULL; - priv->current_stream = NULL; - priv->stream_list = NULL; - priv->timer_id = 0; - priv->in_startup = FALSE; - priv->current_dir = NULL; style_init(self); } @@ -1130,6 +1108,15 @@ struct StartupData { ChimaraGlkPrivate *glk_data; }; +static void +free_startup_data(struct StartupData *startup) +{ + int i = 0; + while(i < startup->args.argc) + g_free(startup->args.argv[i++]); + g_free(startup->args.argv); +} + /* glk_enter() is the actual function called in the new thread in which glk_main() runs. */ static gpointer glk_enter(struct StartupData *startup) @@ -1146,14 +1133,11 @@ glk_enter(struct StartupData *startup) startup->glk_data->in_startup = TRUE; int result = startup->glkunix_startup_code(&startup->args); startup->glk_data->in_startup = FALSE; - - int i = 0; - while(i < startup->args.argc) - g_free(startup->args.argv[i++]); - g_free(startup->args.argv); - - if(!result) + + if(!result) { + free_startup_data(startup); return NULL; + } } /* Run main function */ @@ -1163,6 +1147,7 @@ glk_enter(struct StartupData *startup) g_free(startup); g_signal_emit_by_name(startup->glk_data->self, "started"); glk_main(); + free_startup_data(startup); glk_exit(); /* Run shutdown code in glk_exit() even if glk_main() returns normally */ g_assert_not_reached(); /* because glk_exit() calls g_thread_exit() */ return NULL;