From: Suyeon Hwang Date: Thu, 8 Apr 2021 02:52:51 +0000 (+0900) Subject: Remove not needed function and reorder the code to log the valid uid X-Git-Tag: submit/tizen/20210628.060348~40 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d9815cec96e3d08b9e57c14de345a0fbf424923;p=platform%2Fcore%2Fuifw%2Ftts.git Remove not needed function and reorder the code to log the valid uid Change-Id: I8e51a8a28c7223fb40cc31feecf02c685fd7f43c Signed-off-by: Suyeon Hwang --- diff --git a/client/tts_client.c b/client/tts_client.c index 9c9cdbac..b3afa626 100644 --- a/client/tts_client.c +++ b/client/tts_client.c @@ -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);