Merge "Fix to deallocate memory of sound and speak data" into tizen
[platform/core/uifw/tts.git] / server / ttsd_server.c
index 24365e5..0731597 100644 (file)
@@ -102,8 +102,8 @@ static int __synthesis(int uid, const char* credential)
                }
 
                int pid = ttsd_data_get_pid(uid);
-               char appid[128] = {0, };
-               if (0 != aul_app_get_appid_bypid(pid, appid, sizeof(appid))) {
+               char appid[1024] = {0, };
+               if (0 != aul_app_get_appid_bypid(pid, appid, sizeof(appid) - 1)) {
                        SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get app id");
                }
 
@@ -113,16 +113,7 @@ static int __synthesis(int uid, const char* credential)
 
                        ttsdc_send_set_state_message(pid, uid, APP_STATE_READY);
 
-                       if (NULL != speak_data) {
-                               if (NULL != speak_data->lang)   free(speak_data->lang);
-                               if (NULL != speak_data->text)   free(speak_data->text);
-
-                               speak_data->lang = NULL;
-                               speak_data->text = NULL;
-
-                               free(speak_data);
-                               speak_data = NULL;
-                       }
+                       ttsd_data_clear_speak_data(&speak_data);
 
                        return 0;
                }
@@ -153,16 +144,9 @@ static int __synthesis(int uid, const char* credential)
                        g_wait_timer = ecore_timer_add(0.05, __wait_synthesis, (void*)credential);
                }
 
-               if (NULL != speak_data) {
-                       if (NULL != speak_data->lang)   free(speak_data->lang);
-                       if (NULL != speak_data->text)   free(speak_data->text);
-
-                       speak_data->lang = NULL;
-                       speak_data->text = NULL;
-
-                       free(speak_data);
-                       speak_data = NULL;
-               }
+               ttsd_data_clear_speak_data(&speak_data);
+       } else {
+               ttsd_data_clear_speak_data(&speak_data);
        }
 
        SLOG(LOG_DEBUG, tts_tag(), "@@@ SYNTHESIS  END");
@@ -631,8 +615,8 @@ bool __get_client_for_clean_up(int pid, int uid, app_tts_state_e state, void* us
 
        return true;
 #if 0
-       char appid[128] = {0, };
-       if (0 != aul_app_get_appid_bypid(pid, appid, sizeof(appid))) {
+       char appid[1024] = {0, };
+       if (0 != aul_app_get_appid_bypid(pid, appid, sizeof(appid) - 1)) {
                SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get app id");
        }