From 8c1045c1ae598e5d0e5d4d202ab2321af2179c01 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 15 Mar 2015 03:10:45 +0100 Subject: [PATCH] Create wrapper functions for initing the runloop message queue and freeing it --- retroarch.c | 7 ++----- runloop.c | 13 +++++++++++++ runloop.h | 4 ++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/retroarch.c b/retroarch.c index d06e03a81f..f5260d9757 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2631,14 +2631,11 @@ bool rarch_main_command(unsigned cmd) rarch_main_command(RARCH_CMD_AUTOSAVE_INIT); break; case RARCH_CMD_MSG_QUEUE_DEINIT: - if (g_runloop.msg_queue) - msg_queue_free(g_runloop.msg_queue); - g_runloop.msg_queue = NULL; + rarch_main_msg_queue_free(); break; case RARCH_CMD_MSG_QUEUE_INIT: rarch_main_command(RARCH_CMD_MSG_QUEUE_DEINIT); - if (!g_runloop.msg_queue) - rarch_assert(g_runloop.msg_queue = msg_queue_new(8)); + rarch_main_msg_queue_init(); rarch_main_data_init_queues(); break; case RARCH_CMD_BSV_MOVIE_DEINIT: diff --git a/runloop.c b/runloop.c index ce8adbe02e..474056c53b 100644 --- a/runloop.c +++ b/runloop.c @@ -908,6 +908,19 @@ void rarch_main_msg_queue_push(const char *msg, unsigned prio, unsigned duration msg_queue_push(g_runloop.msg_queue, msg, prio, duration); } +void rarch_main_msg_queue_free(void) +{ + if (g_runloop.msg_queue) + msg_queue_free(g_runloop.msg_queue); + g_runloop.msg_queue = NULL; +} + +void rarch_main_msg_queue_init(void) +{ + if (!g_runloop.msg_queue) + rarch_assert(g_runloop.msg_queue = msg_queue_new(8)); +} + /** * rarch_main_iterate: * diff --git a/runloop.h b/runloop.h index 85adcf3671..f3a7988b33 100644 --- a/runloop.h +++ b/runloop.h @@ -181,6 +181,10 @@ void rarch_main_msg_queue_push(const char *msg, unsigned prio, const char *rarch_main_msg_queue_pull(void); +void rarch_main_msg_queue_free(void); + +void rarch_main_msg_queue_init(void); + void rarch_main_data_iterate(void); void rarch_main_data_init_queues(void);