Remove not needed function and reorder the code to log the valid uid 29/256629/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Thu, 8 Apr 2021 02:52:51 +0000 (11:52 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Thu, 8 Apr 2021 05:11:06 +0000 (14:11 +0900)
Change-Id: I8e51a8a28c7223fb40cc31feecf02c685fd7f43c
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/tts_client.c

index 9c9cdba..b3afa62 100644 (file)
@@ -88,69 +88,26 @@ static inline void __set_supported_voice_cb(tts_client_s* client, tts_supported_
        client->supported_voice_user_data = user_data;
 }
 
-static inline void __reset_client_data(tts_client_s* client) {
-       client->tts = NULL;
-       client->pid = INVALID_HANDLE;
-       client->uid = INVALID_HANDLE;
-       client->current_utt_id = 0;
-
-       client->state_changed_cb = NULL;
-       client->state_changed_user_data = NULL;
-
-       client->utt_started_cb = NULL;
-       client->utt_started_user_data = NULL;
-       client->utt_completed_cb = NULL;
-       client->utt_completed_user_data = NULL;
-
-       client->error_cb = NULL;
-       client->error_user_data = NULL;
-       client->default_voice_changed_cb = NULL;
-       client->default_voice_changed_user_data = NULL;
-       client->supported_voice_cb = NULL;
-       client->supported_voice_user_data = NULL;
-
-       client->mode = TTS_MODE_DEFAULT;
-       client->before_state = TTS_STATE_CREATED;
-       client->current_state = TTS_STATE_CREATED;
-
-       client->cb_ref_count = 0;
-
-       client->utt_id = 0;
-       client->reason = 0;
-       client->err_msg = NULL;
-
-       client->hello_timer = NULL;
-       client->start_listening = false;
-
-       client->credential = NULL;
-       client->credential_needed = false;
-       client->internal = false;
-
-       client->text_repeat = NULL;
-
-       client->notify_error_timer = NULL;
-       client->notify_state_timer = NULL;
-}
-
 int tts_client_new(tts_h* tts)
 {
-       tts_client_s* client = NULL;
-       client = (tts_client_s*)calloc(1, sizeof(tts_client_s));
+       tts_client_s* client = (tts_client_s*)calloc(1, sizeof(tts_client_s));
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to allocate memory");
                return TTS_ERROR_OUT_OF_MEMORY;
        }
+
        tts_h temp = (tts_h)calloc(1, sizeof(struct tts_s));
        if (NULL == temp) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to allocate memory");
                free(client);
                return TTS_ERROR_OUT_OF_MEMORY;
        }
+
        temp->handle = __client_generate_uid(getpid());
        temp->connected = false;
+       temp->rpc_h = NULL;
 
        /* initialize client data */
-       __reset_client_data(client);
        client->tts = temp;
        client->pid = getpid();
        client->uid = temp->handle;
@@ -192,24 +149,17 @@ int tts_client_destroy(tts_h tts)
                                        /* wait for release callback function */
                                }
 
-                               if (NULL != data->err_msg) {
-                                       free(data->err_msg);
-                               }
-
-                               if (NULL != data->credential) {
-                                       free(data->credential);
-                               }
+                               int uid = data->uid;
 
-                               if (NULL != data->text_repeat) {
-                                       free(data->text_repeat);
-                               }
+                               free(data->err_msg);
+                               free(data->credential);
+                               free(data->text_repeat);
+                               memset(data, 0, sizeof(tts_client_s));
 
-                               __reset_client_data(data);
-                               int uid = data->uid;
                                free(data);
-                               free(tts);
-
                                data = NULL;
+
+                               free(tts);
                                tts = NULL;
 
                                g_list_free(iter);