From: Wook Song Date: Thu, 23 Feb 2017 05:55:27 +0000 (+0900) Subject: pmqos: Add cleanup function on normal exit X-Git-Tag: submit/tizen/20170328.004502~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c7424f5071cccf3497497db4952f6c22aac289c4;p=platform%2Fcore%2Fsystem%2Fpass.git pmqos: Add cleanup function on normal exit This patch adds a cleanup function, that frees all the dynamically allocated data and assigns 0 to the static variables. This cleanup function is invoked when the pmqos module is normally terminated. Change-Id: I0471f3ca13a4ba8a385b7829afab16dbf68f4988 Signed-off-by: Wook Song --- diff --git a/src/pmqos/pmqos.c b/src/pmqos/pmqos.c index 395a513..ea40cb7 100644 --- a/src/pmqos/pmqos.c +++ b/src/pmqos/pmqos.c @@ -49,7 +49,7 @@ static dd_list *pmqos_head; static Ecore_Timer *unlock_timer; static struct timespec unlock_timer_start_st; static struct timespec unlock_timer_end_st; -static struct pmqos_cpu unlock_timer_owner = {"NULL", 0}; +static struct pmqos_cpu unlock_timer_owner = {"", 0}; int set_pmqos(const char *name, int val) { @@ -455,9 +455,30 @@ static void pmqos_init(void *data) register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done, NULL); } +static void pmqos_free(void) +{ + /* Assign 0 to static variables */ + memset(&unlock_timer_start_st, 0, sizeof(struct timespec)); + memset(&unlock_timer_end_st, 0, sizeof(struct timespec)); + memset(&unlock_timer_owner, 0, sizeof(struct pmqos_cpu)); + + /* Clean up pmqos_head */ + if (pmqos_head) { + DD_LIST_FREE_LIST_FULL(pmqos_head, free); + pmqos_head = NULL; + } + + /* Clean up unlock_timer */ + if (unlock_timer) { + ecore_timer_del(unlock_timer); + unlock_timer = NULL; + } +} + static void pmqos_exit(void *data) { unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done); + pmqos_free(); } static const struct device_ops pmqos_device_ops = {