From: SeokYeon Hwang Date: Tue, 18 Aug 2015 07:29:09 +0000 (+0900) Subject: emul_state: freed memories those are allocated in runtime X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~40^2~191 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8a182677b286a14d1b6fcb6651eff6eb71d45dd2;p=sdk%2Femulator%2Fqemu.git emul_state: freed memories those are allocated in runtime Change-Id: I5546cd3f680dc5b253a05235228ed60fbd6f00e5 Signed-off-by: SeokYeon Hwang --- diff --git a/tizen/src/emul_state.c b/tizen/src/emul_state.c index 42d0afaac9..3ea18a7a33 100644 --- a/tizen/src/emul_state.c +++ b/tizen/src/emul_state.c @@ -53,6 +53,7 @@ extern bool hax_allowed; #include "qmp-commands.h" #include "fsdev/qemu-fsdev.h" +#include "emulator.h" #include "emulator_options.h" #include "hw/virtio/maru_virtio_touchscreen.h" #include "hw/virtio/maru_virtio_evdi.h" @@ -359,15 +360,19 @@ const char *launch_conf_file = NULL; // bin path // only set by osutil-{OS}.c when start up -const char *bin_path = ""; +const char *bin_path = NULL; const char *get_bin_path(void) { - return bin_path; + if (bin_path) { + return bin_path; + } + + return ""; } // emulator kernel log file -static const char *kernel_log_redirect_file; +static const char *kernel_log_redirect_file = NULL; const char *get_kernel_log_redirect_file(void) { @@ -392,7 +397,7 @@ const char *get_kernel_log_redirect_file(void) } // emulator log file -static const char *log_redirect_file; +static const char *log_redirect_file = NULL; #ifdef CONFIG_WIN32 // for checking Windows version @@ -517,7 +522,7 @@ const char *get_http_proxy_addr(void) g_strfreev(token); } - http_proxy_addr = ""; + http_proxy_addr = g_strdup(""); LOG_INFO("HTTP proxy address is not set.\n"); @@ -817,3 +822,37 @@ bool is_skin_enabled(void) return skin_enabled; } #endif + +static void emul_state_notify_exit(Notifier *notifier, void *data) +{ + g_free((void *)launch_conf_file); + launch_conf_file = NULL; + + g_free((void *)bin_path); + bin_path = NULL; + + g_free((void *)kernel_log_redirect_file); + kernel_log_redirect_file = NULL; + + g_free((void *)log_redirect_file); + log_redirect_file = NULL; + + g_free((void *)drive_image_file); + drive_image_file = NULL; + + g_free((void *)http_proxy_addr); + http_proxy_addr = NULL; + + g_free((void *)vm_name); + vm_name = NULL; + + g_free((void *)vm_data_path); + vm_data_path = NULL; +} + +static Notifier emul_state_exit = { .notify = emul_state_notify_exit }; + +void init_emul_state(void) +{ + emulator_add_exit_notifier(&emul_state_exit); +} diff --git a/tizen/src/emul_state.h b/tizen/src/emul_state.h index 45bbdae3a5..8aef4c889a 100644 --- a/tizen/src/emul_state.h +++ b/tizen/src/emul_state.h @@ -206,4 +206,5 @@ bool is_skin_enabled(void); void set_vm_data_path(const char *path); #endif +void init_emul_state(void); #endif /* __EMUL_STATE_H__ */ diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index 485b74acf5..a6baba5153 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -380,6 +380,8 @@ static int emulator_main(int argc, char *argv[], char **envp) LOG_INFO("Start emulator...\n"); print_options_info(); + init_emul_state(); + LOG_INFO("qemu main start...\n"); qemu_main(_qemu_argc, _qemu_argv, envp);