From 8f0df02ba2d9093c37b912b7242b9971fc78023c Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Tue, 7 Feb 2017 22:07:02 +0900 Subject: [PATCH] Add to release memory for sound data Change-Id: I8ad7437b60fbe0449ea06529ab8d635a5231ebf5 Signed-off-by: sooyeon.kim --- common/tts_config_parser.c | 38 ++++- engine-parser/src/tts-engine-parser.c | 264 +++++++++++----------------------- server/ttsd_player.c | 44 ++++++ 3 files changed, 166 insertions(+), 180 deletions(-) diff --git a/common/tts_config_parser.c b/common/tts_config_parser.c index f9f5f8d..82f8428 100755 --- a/common/tts_config_parser.c +++ b/common/tts_config_parser.c @@ -94,6 +94,7 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info if (NULL == temp) { SLOG(LOG_ERROR, tts_tag(), "[ERROR] Out of memory"); xmlFreeDoc(doc); + doc = NULL; return -1; } @@ -113,6 +114,7 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info } temp->name = strdup((char*)key); xmlFree(key); + key = NULL; } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_NAME); } @@ -125,6 +127,7 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info } temp->uuid = strdup((char*)key); xmlFree(key); + key = NULL; } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_ID); } @@ -137,6 +140,7 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info } temp->setting = strdup((char*)key); xmlFree(key); + key = NULL; } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_SETTING); } @@ -164,6 +168,7 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info temp_voice->type = (int)TTS_CONFIG_VOICE_TYPE_USER_DEFINED; } xmlFree(attr); + attr = NULL; } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_VOICE_TYPE); free(temp_voice); @@ -179,6 +184,7 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info } temp_voice->language = strdup((char*)key); xmlFree(key); + key = NULL; temp->voices = g_slist_append(temp->voices, temp_voice); } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_VOICE); @@ -326,6 +332,7 @@ int tts_parser_load_config(tts_config_s** config_info) doc = xmlParseFile(TTS_DEFAULT_CONFIG); if (doc == NULL) { SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse file error : %s", TTS_DEFAULT_CONFIG); + xmlCleanupParser(); return -1; } is_default_open = true; @@ -342,6 +349,7 @@ int tts_parser_load_config(tts_config_s** config_info) if (TTS_RETRY_COUNT == retry_count) { SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse file error : %s", TTS_CONFIG); + xmlCleanupParser(); return -1; } } @@ -352,6 +360,7 @@ int tts_parser_load_config(tts_config_s** config_info) SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document"); xmlFreeDoc(doc); doc = NULL; + xmlCleanupParser(); return -1; } @@ -359,6 +368,7 @@ int tts_parser_load_config(tts_config_s** config_info) SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong type, root node is NOT %s", TTS_TAG_CONFIG_BASE_TAG); xmlFreeDoc(doc); doc = NULL; + xmlCleanupParser(); return -1; } @@ -367,6 +377,7 @@ int tts_parser_load_config(tts_config_s** config_info) SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document"); xmlFreeDoc(doc); doc = NULL; + xmlCleanupParser(); return -1; } @@ -376,6 +387,8 @@ int tts_parser_load_config(tts_config_s** config_info) if (NULL == temp) { SLOG(LOG_ERROR, tts_tag(), "[ERROR] Out of memory"); xmlFreeDoc(doc); + doc = NULL; + xmlCleanupParser(); return -1; } @@ -393,6 +406,7 @@ int tts_parser_load_config(tts_config_s** config_info) } temp->engine_id = strdup((char*)key); xmlFree(key); + key = NULL; } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] engine id is NULL"); } @@ -405,6 +419,7 @@ int tts_parser_load_config(tts_config_s** config_info) } temp->setting = strdup((char*)key); xmlFree(key); + key = NULL; } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] setting path is NULL"); } @@ -421,6 +436,7 @@ int tts_parser_load_config(tts_config_s** config_info) } xmlFree(key); + key = NULL; } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] voice type is NULL"); } @@ -439,6 +455,7 @@ int tts_parser_load_config(tts_config_s** config_info) } xmlFree(key); + key = NULL; } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] voice type is NULL"); } @@ -451,6 +468,7 @@ int tts_parser_load_config(tts_config_s** config_info) } temp->language = strdup((char*)key); xmlFree(key); + key = NULL; } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] engine uuid is NULL"); } @@ -468,6 +486,7 @@ int tts_parser_load_config(tts_config_s** config_info) if (NULL != key) { temp->pitch = atoi((char*)key); xmlFree(key); + key = NULL; } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] Pitch is NULL"); } @@ -525,6 +544,8 @@ int tts_parser_unload_config(tts_config_s* config_info) config_info = NULL; } + xmlCleanupParser(); + return 0; } @@ -554,6 +575,7 @@ int tts_parser_copy_xml(const char* original, const char* destination) } xmlFreeDoc(doc); + doc = NULL; SLOG(LOG_DEBUG, tts_tag(), "[SUCCESS] Copying xml"); return 0; @@ -605,7 +627,7 @@ int tts_parser_set_engine(const char* engine_id, const char* setting, const char default: xmlNodeSetContent(cur, (const xmlChar*)TTS_TAG_VOICE_TYPE_FEMALE); break; } } - + cur = cur->next; } @@ -869,8 +891,10 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic *engine = strdup((char*)key_new); } xmlFree(key_new); + key_new = NULL; } xmlFree(key_old); + key_old = NULL; } } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different"); @@ -891,8 +915,10 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic *setting = strdup((char*)key_new); } xmlFree(key_new); + key_new = NULL; } xmlFree(key_old); + key_old = NULL; } } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different"); @@ -913,8 +939,10 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic } } xmlFree(key_new); + key_new = NULL; } xmlFree(key_old); + key_old = NULL; } } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different"); @@ -935,8 +963,10 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic *language = strdup((char*)key_new); } xmlFree(key_new); + key_new = NULL; } xmlFree(key_old); + key_old = NULL; } } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different"); @@ -961,8 +991,10 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic } } xmlFree(key_new); + key_new = NULL; } xmlFree(key_old); + key_old = NULL; } } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different"); @@ -979,8 +1011,10 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic *speech_rate = atoi((char*)key_new); } xmlFree(key_new); + key_new = NULL; } xmlFree(key_old); + key_old = NULL; } } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different"); @@ -997,8 +1031,10 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic *pitch = atoi((char*)key_new); } xmlFree(key_new); + key_new = NULL; } xmlFree(key_old); + key_old = NULL; } } else { SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different"); diff --git a/engine-parser/src/tts-engine-parser.c b/engine-parser/src/tts-engine-parser.c index ca8f5e7..b5d82d2 100644 --- a/engine-parser/src/tts-engine-parser.c +++ b/engine-parser/src/tts-engine-parser.c @@ -68,6 +68,10 @@ #define TTS_METADATA_CREDENTIAL_REQUIRED "http://tizen.org/metadata/tts-engine/credential-required" #define TTS_METADATA_SETTING "http://tizen.org/metadata/tts-engine/setting" +/* Define Macro */ +#define FREE(x) { if (NULL != x) { free(x); x = NULL; } } +#define G_FREE(x) { if (NULL != x) { g_free(x); x = NULL; } } + typedef struct metadata { const char *key; const char *value; @@ -140,22 +144,11 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t if (NULL == dir_config_base || NULL == dir_home || NULL == dir_engine_base || NULL == dir_engine_info) { LOGE("[ERROR] Fail to allocate memory"); - if (NULL != dir_config_base) { - free(dir_config_base); - dir_config_base = NULL; - } - if (NULL != dir_home) { - free(dir_home); - dir_home = NULL; - } - if (NULL != dir_engine_base) { - free(dir_engine_base); - dir_engine_base = NULL; - } - if (NULL != dir_engine_info) { - free(dir_engine_info); - dir_engine_info = NULL; - } + FREE(dir_config_base) + FREE(dir_home) + FREE(dir_engine_base) + FREE(dir_engine_info) + return -1; } @@ -168,14 +161,10 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t LOGE("[INFO] No directory : %s, errno : %d", dir_config_base, errno); if (0 != mkdir(dir_config_base, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_config_base, errno); - free(dir_config_base); - dir_config_base = NULL; - free(dir_home); - dir_home = NULL; - free(dir_engine_base); - dir_engine_base = NULL; - free(dir_engine_info); - dir_engine_info = NULL; + FREE(dir_config_base) + FREE(dir_home) + FREE(dir_engine_base) + FREE(dir_engine_info) return -1; } else { LOGD("Success to make directory : %s", dir_config_base); @@ -192,14 +181,10 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t LOGE("[INFO] No directory : %s, errno : %d", dir_home, errno); if (0 != mkdir(dir_home, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_home, errno); - free(dir_config_base); - dir_config_base = NULL; - free(dir_home); - dir_home = NULL; - free(dir_engine_base); - dir_engine_base = NULL; - free(dir_engine_info); - dir_engine_info = NULL; + FREE(dir_config_base) + FREE(dir_home) + FREE(dir_engine_base) + FREE(dir_engine_info) return -1; } else { LOGD("Success to make directory : %s", dir_home); @@ -216,14 +201,10 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t LOGE("[INFO] No directory : %s, errno : %d", dir_engine_base, errno); if (0 != mkdir(dir_engine_base, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_engine_base, errno); - free(dir_config_base); - dir_config_base = NULL; - free(dir_home); - dir_home = NULL; - free(dir_engine_base); - dir_engine_base = NULL; - free(dir_engine_info); - dir_engine_info = NULL; + FREE(dir_config_base) + FREE(dir_home) + FREE(dir_engine_base) + FREE(dir_engine_info) return -1; } else { LOGD("Success to make directory : %s", dir_engine_base); @@ -240,14 +221,10 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t LOGE("[INFO] No directory : %s, errno : %d", dir_engine_info, errno); if (0 != mkdir(dir_engine_info, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_engine_info, errno); - free(dir_config_base); - dir_config_base = NULL; - free(dir_home); - dir_home = NULL; - free(dir_engine_base); - dir_engine_base = NULL; - free(dir_engine_info); - dir_engine_info = NULL; + FREE(dir_config_base) + FREE(dir_home) + FREE(dir_engine_base) + FREE(dir_engine_info) return -1; } else { LOGD("Success to make directory : %s", dir_engine_info); @@ -272,14 +249,10 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t } } - free(dir_config_base); - dir_config_base = NULL; - free(dir_home); - dir_home = NULL; - free(dir_engine_base); - dir_engine_base = NULL; - free(dir_engine_info); - dir_engine_info = NULL; + FREE(dir_config_base) + FREE(dir_home) + FREE(dir_engine_base) + FREE(dir_engine_info) LOGD("==="); return 0; @@ -326,8 +299,7 @@ static int __remove_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid) } } - free(dir_engine_info); - dir_engine_info = NULL; + FREE(dir_engine_info) LOGD("==="); return 0; @@ -367,8 +339,8 @@ static void __insert_language_from_metadata(xmlNodePtr root, const char *languag } xmlAddChild(root, voices_node); - free(tmp_free); - tmp_free = NULL; + FREE(tmp_lang) + FREE(tmp_free) } static int __write_metadata_inxml(const char *pkgid, const char *appid, GList *list) @@ -476,7 +448,7 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * LOGE("[ERROR] Fail to get target uid"); g_object_unref(g_guser); g_guser = NULL; - g_free(g_user_type); + G_FREE(g_user_type) return -1; } @@ -485,14 +457,14 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * LOGD("[DEBUG] usertype: %s", g_user_type); if (0 >= g_list_length(list)) { LOGE("[ERROR] No Engine Metadata"); - g_free(g_user_type); + G_FREE(g_user_type) return 0; } if (0 != __write_metadata_inxml(pkgid, appid, list)) { LOGE("[ERROR] Fail to write metadata in the xml"); xmlFreeDoc(g_doc); - g_free(g_user_type); + G_FREE(g_user_type) return -1; } @@ -504,31 +476,20 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * if (NULL == g_dir_config_base || NULL == g_dir_home || NULL == g_dir_engine_base || NULL == g_dir_engine_info) { LOGE("[ERROR] Fail to allocate memory"); - if (NULL != g_dir_config_base) { - free(g_dir_config_base); - g_dir_config_base = NULL; - } - if (NULL != g_dir_home) { - free(g_dir_home); - g_dir_home = NULL; - } - if (NULL != g_dir_engine_base) { - free(g_dir_engine_base); - g_dir_engine_base = NULL; - } - if (NULL != g_dir_engine_info) { - free(g_dir_engine_info); - g_dir_engine_info = NULL; - } + FREE(g_dir_config_base) + FREE(g_dir_home) + FREE(g_dir_engine_base) + FREE(g_dir_engine_info) + xmlFreeDoc(g_doc); - g_free(g_user_type); + G_FREE(g_user_type) return -1; } if (0 != __save_engine_info_xml(pkgid, g_user_type, g_uid, g_gid)) { LOGE("[ERROR] Fail to make engine info file"); xmlFreeDoc(g_doc); - g_free(g_user_type); + G_FREE(g_user_type) return -1; } @@ -549,7 +510,7 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * gus = gum_user_service_create_sync(TRUE); if (!gus) { LOGE("Failed to create gum user service"); - g_free(g_user_type); + G_FREE(g_user_type) return -1; } @@ -562,7 +523,7 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * LOGE("Failed to get gum user list"); g_object_unref(gus); gus = NULL; - g_free(g_user_type); + G_FREE(g_user_type) return -1; } @@ -572,10 +533,8 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * while (iter != NULL) { user = (GumUser*) iter->data; g_object_get(G_OBJECT(user), "uid", &uid, NULL); - if (NULL != home_dir) { - free(home_dir); - home_dir = NULL; - } + FREE(home_dir) + g_object_get(G_OBJECT(user), "gid", &gid, NULL); g_object_get(G_OBJECT(user), "homedir", &home_dir, NULL); g_object_get(G_OBJECT(user), "usertype", &gumut, NULL); @@ -598,25 +557,14 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * if (NULL == g_dir_config_base || NULL == g_dir_home || NULL == g_dir_engine_base || NULL == g_dir_engine_info) { LOGE("[ERROR] Fail to allocate memory"); - if (NULL != g_dir_config_base) { - free(g_dir_config_base); - g_dir_config_base = NULL; - } - if (NULL != g_dir_home) { - free(g_dir_home); - g_dir_home = NULL; - } - if (NULL != g_dir_engine_base) { - free(g_dir_engine_base); - g_dir_engine_base = NULL; - } - if (NULL != g_dir_engine_info) { - free(g_dir_engine_info); - g_dir_engine_info = NULL; - } + FREE(g_dir_config_base) + FREE(g_dir_home) + FREE(g_dir_engine_base) + FREE(g_dir_engine_info) gum_user_service_list_free(users); g_object_unref(gus); gus = NULL; + G_FREE(user_type) return -1; } snprintf(g_dir_config_base, strlen(home_dir) + 14, "%s/share/.voice", home_dir); @@ -630,29 +578,20 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * LOGE("[ERROR] Fail to make engine info file"); } - free(g_dir_config_base); - g_dir_config_base = NULL; - free(g_dir_home); - g_dir_home = NULL; - free(g_dir_engine_base); - g_dir_engine_base = NULL; - free(g_dir_engine_info); - g_dir_engine_info = NULL; + FREE(g_dir_config_base) + FREE(g_dir_home) + FREE(g_dir_engine_base) + FREE(g_dir_engine_info) - g_free(user_type); - user_type = NULL; - free(home_dir); - home_dir = NULL; + G_FREE(user_type) + FREE(home_dir) iter = g_list_next(iter); } else { iter = g_list_next(iter); } - if (NULL != user_type) { - g_free(user_type); - user_type = NULL; - } + G_FREE(user_type) } gum_user_service_list_free(users); @@ -667,7 +606,7 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * LOGE("[ERROR] Invalid uid"); g_object_unref(g_guser); g_guser = NULL; - g_free(g_user_type); + G_FREE(g_user_type) return 0; } else { LOGD("TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/")); @@ -678,7 +617,7 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * LOGE("[ERROR] No Engine Metadata"); g_object_unref(g_guser); g_guser = NULL; - g_free(g_user_type); + G_FREE(g_user_type) return 0; } @@ -687,7 +626,7 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * xmlFreeDoc(g_doc); g_object_unref(g_guser); g_guser = NULL; - g_free(g_user_type); + G_FREE(g_user_type) return -1; } @@ -698,26 +637,14 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * if (NULL == g_dir_config_base || NULL == g_dir_home || NULL == g_dir_engine_base || NULL == g_dir_engine_info) { LOGE("[ERROR] Fail to allocate memory"); - if (NULL != g_dir_config_base) { - free(g_dir_config_base); - g_dir_config_base = NULL; - } - if (NULL != g_dir_home) { - free(g_dir_home); - g_dir_home = NULL; - } - if (NULL != g_dir_engine_base) { - free(g_dir_engine_base); - g_dir_engine_base = NULL; - } - if (NULL != g_dir_engine_info) { - free(g_dir_engine_info); - g_dir_engine_info = NULL; - } + FREE(g_dir_config_base) + FREE(g_dir_home) + FREE(g_dir_engine_base) + FREE(g_dir_engine_info) xmlFreeDoc(g_doc); g_object_unref(g_guser); g_guser = NULL; - g_free(g_user_type); + G_FREE(g_user_type) return -1; } @@ -728,7 +655,7 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * g_object_unref(g_guser); g_guser = NULL; } - g_free(g_user_type); + G_FREE(g_user_type) return -1; } } @@ -738,24 +665,12 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * g_object_unref(g_guser); g_guser = NULL; } - g_free(g_user_type); + G_FREE(g_user_type) - if (NULL != g_dir_config_base) { - free(g_dir_config_base); - g_dir_config_base = NULL; - } - if (NULL != g_dir_home) { - free(g_dir_home); - g_dir_home = NULL; - } - if (NULL != g_dir_engine_base) { - free(g_dir_engine_base); - g_dir_engine_base = NULL; - } - if (NULL != g_dir_engine_info) { - free(g_dir_engine_info); - g_dir_engine_info = NULL; - } + FREE(g_dir_config_base) + FREE(g_dir_home) + FREE(g_dir_engine_base) + FREE(g_dir_engine_info) return 0; } @@ -804,7 +719,7 @@ int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList LOGE("[ERROR] Fail to get target uid"); g_object_unref(g_guser); g_guser = NULL; - g_free(g_user_type); + G_FREE(g_user_type) return -1; } @@ -816,7 +731,7 @@ int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList g_dir_engine_info = strdup(TTS_GLOBAL_ENGINE_INFO); if (NULL == g_dir_engine_info) { LOGE("[ERROR] Fail to allocate memory"); - g_free(g_user_type); + G_FREE(g_user_type) return -1; } @@ -843,7 +758,7 @@ int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList gus = gum_user_service_create_sync(TRUE); if (!gus) { LOGE("Failed to create gum user service"); - g_free(g_user_type); + G_FREE(g_user_type) return -1; } @@ -856,7 +771,7 @@ int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList LOGE("Failed to get gum user list"); g_object_unref(gus); gus = NULL; - g_free(g_user_type); + G_FREE(g_user_type) return -1; } @@ -866,10 +781,7 @@ int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList while (iter != NULL) { user = (GumUser*) iter->data; g_object_get(G_OBJECT(user), "uid", &uid, NULL); - if (NULL != home_dir) { - free(home_dir); - home_dir = NULL; - } + FREE(home_dir) g_object_get(G_OBJECT(user), "homedir", &home_dir, NULL); g_object_get(G_OBJECT(user), "usertype", &gumut, NULL); user_type = g_strdup(gum_user_type_to_string(gumut)); @@ -886,6 +798,7 @@ int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList gum_user_service_list_free(users); g_object_unref(gus); gus = NULL; + G_FREE(user_type) return -1; } @@ -902,13 +815,9 @@ int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList LOGE("[ERROR] Fail to remove engine info file"); } - free(home_dir); - home_dir = NULL; - - free(g_dir_engine_info); - g_dir_engine_info = NULL; - - g_free(user_type); + FREE(home_dir) + FREE(g_dir_engine_info) + G_FREE(user_type) LOGD("Finish release memory"); iter = g_list_next(iter); @@ -930,7 +839,7 @@ int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList LOGE("[ERROR] Invalid uid"); g_object_unref(g_guser); g_guser = NULL; - g_free(g_user_type); + G_FREE(g_user_type) return -1; } else { LOGD("TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/")); @@ -942,7 +851,7 @@ int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList LOGE("[ERROR] Fail to allocate memory"); g_object_unref(g_guser); g_guser = NULL; - g_free(g_user_type); + G_FREE(g_user_type) return -1; } @@ -956,12 +865,9 @@ int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList g_object_unref(g_guser); g_guser = NULL; } - g_free(g_user_type); + G_FREE(g_user_type) - if (NULL != g_dir_engine_info) { - free(g_dir_engine_info); - g_dir_engine_info = NULL; - } + FREE(g_dir_engine_info) LOGD(""); return 0; diff --git a/server/ttsd_player.c b/server/ttsd_player.c index 529a41d..d6e7be5 100644 --- a/server/ttsd_player.c +++ b/server/ttsd_player.c @@ -338,6 +338,13 @@ static void __play_thread(void *data, Ecore_Thread *thread) SLOG(LOG_WARN, tts_tag(), "[Send WARNIING] Current player is not valid"); /* unset volume policy, volume will be 100% */ __unset_policy_for_playing(); + + if (NULL != sound_data->data) { + free(sound_data->data); + sound_data->data = NULL; + } + free(sound_data); + sound_data = NULL; return; } @@ -362,6 +369,12 @@ static void __play_thread(void *data, Ecore_Thread *thread) SLOG(LOG_WARN, tts_tag(), "[Send WARNIING] Current player is not valid"); /* unset volume policy, volume will be 100% */ __unset_policy_for_playing(); + if (NULL != sound_data->data) { + free(sound_data->data); + sound_data->data = NULL; + } + free(sound_data); + sound_data = NULL; return; } if (0 != ttsdc_send_utt_finish_message(pid, player->uid, sound_data->utt_id)) { @@ -384,6 +397,14 @@ static void __play_thread(void *data, Ecore_Thread *thread) SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to create audio out"); /* unset volume policy, volume will be 100% */ __unset_policy_for_playing(); + + if (NULL != sound_data->data) { + free(sound_data->data); + sound_data->data = NULL; + } + free(sound_data); + sound_data = NULL; + return; } __set_policy_for_playing(40); @@ -407,6 +428,15 @@ static void __play_thread(void *data, Ecore_Thread *thread) g_playing_info = NULL; /* unset volume policy, volume will be 100% */ __unset_policy_for_playing(); + + if (NULL != sound_data->data) { + free(sound_data->data); + sound_data->data = NULL; + } + + free(sound_data); + sound_data = NULL; + return; } SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Prepare audio"); @@ -503,6 +533,13 @@ static void __play_thread(void *data, Ecore_Thread *thread) SLOG(LOG_WARN, tts_tag(), "[Send WARNIING] Current player is not valid"); /* unset volume policy, volume will be 100% */ __unset_policy_for_playing(); + if (NULL != sound_data->data) { + free(sound_data->data); + sound_data->data = NULL; + } + + free(sound_data); + sound_data = NULL; return; } @@ -511,6 +548,13 @@ static void __play_thread(void *data, Ecore_Thread *thread) pid, player->uid, sound_data->utt_id); /* unset volume policy, volume will be 100% */ __unset_policy_for_playing(); + if (NULL != sound_data->data) { + free(sound_data->data); + sound_data->data = NULL; + } + + free(sound_data); + sound_data = NULL; return; } -- 2.7.4