From feef97f0dfafa6cab5f8364664a2cd8fd0381b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Higor=20Eur=C3=ADpedes?= Date: Tue, 19 May 2015 13:58:22 -0300 Subject: [PATCH] Set the global variable to NULL on free in driver.c and runloop.c --- driver.c | 8 ++++---- runloop.c | 12 +++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/driver.c b/driver.c index 2535ac77c8..7f6e8e2a3c 100644 --- a/driver.c +++ b/driver.c @@ -30,14 +30,14 @@ #include "config.h" #endif -static driver_t *g_driver; +static driver_t *g_driver = NULL; void driver_free(void) { - driver_t *driver = driver_get_ptr(); + if (g_driver) + free(g_driver); - if (driver) - free(driver); + g_driver = NULL; } static driver_t *driver_new(void) diff --git a/runloop.c b/runloop.c index a4cc178fe1..8a06ddc37c 100644 --- a/runloop.c +++ b/runloop.c @@ -35,9 +35,8 @@ #include "netplay.h" #endif -static struct runloop *g_runloop; - -static struct global *g_extern; +static struct runloop *g_runloop = NULL; +static struct global *g_extern = NULL; /** * check_pause: @@ -941,12 +940,11 @@ runloop_t *rarch_main_get_ptr(void) void rarch_main_state_free(void) { - runloop_t *runloop = rarch_main_get_ptr(); - - if (!runloop) + if (!g_runloop) return; - free(runloop); + free(g_runloop); + g_runloop = NULL; } void rarch_main_global_free(void)