PLAYER_INSTANCE_CHECK(player);
PLAYER_TRACE_BEGIN("MM:PLAYER:CREATE");
player_s *handle;
- handle = (player_s *)malloc(sizeof(player_s));
- if (handle != NULL)
- memset(handle, 0, sizeof(player_s));
- else {
+ handle = g_try_new0(player_s, 1);
+ if (!handle) {
LOGE("[%s] PLAYER_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, PLAYER_ERROR_OUT_OF_MEMORY);
return PLAYER_ERROR_OUT_OF_MEMORY;
}
if (ret != MM_ERROR_NONE) {
LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION);
__player_update_state(handle, PLAYER_INTERNAL_STATE_NONE);
- free(handle);
+ g_free(handle);
handle = NULL;
return __player_convert_error_code(ret, (char *)__FUNCTION__);
} else {
g_mutex_clear(&handle->message_queue_lock);
g_cond_clear(&handle->message_queue_cond);
- free(handle);
+ g_free(handle);
handle = NULL;
LOGI("[%s] End", __FUNCTION__);
PLAYER_TRACE_END();
return FALSE;
}
- export_data = g_new0(muse_player_export_data_s, 1);
+ export_data = g_try_new0(muse_player_export_data_s, 1);
if (export_data == NULL) {
LOGE("failed to alloc export_data");
return FALSE;
player_msg_get(pid, muse_server_module_get_msg(module));
/* init handle */
- muse_player = (muse_player_handle_s *)malloc(sizeof(muse_player_handle_s));
- if (muse_player == NULL) {
+ muse_player = g_try_new0(muse_player_handle_s, 1);
+ if (!muse_player) {
ret = PLAYER_ERROR_OUT_OF_MEMORY;
LOGE("failed to alloc handle 0x%x", ret);
PLAYER_RETURN_MSG(api, ret, module);
return ret;
}
- memset(muse_player, 0x0, sizeof(muse_player_handle_s));
/* get buffer mgr */
if (muse_server_ipc_get_bufmgr(&muse_player->bufmgr) != MM_ERROR_NONE) {
ERROR:
legacy_player_destroy(muse_player->player_handle);
- free(muse_player);
+ g_free(muse_player);
muse_player = NULL;
PLAYER_RETURN_MSG(api, ret, module);
return ret;
muse_player->bufmgr = NULL;
- free(muse_player);
+ g_free(muse_player);
muse_player = NULL;
PLAYER_RETURN_MSG(api, ret, module);
muse_player = (muse_player_handle_s *)muse_server_ipc_get_handle(module);
- prepare_data = g_new(prepare_data_s, 1);
+ prepare_data = g_try_new(prepare_data_s, 1);
if (!prepare_data) {
ret = PLAYER_ERROR_INVALID_OPERATION;
goto ERROR;