void tpm_comm_destroy()

in src/tpm_comm_linux.c [343:364]


void tpm_comm_destroy(TPM_COMM_HANDLE handle)
{
    if (handle)
    {
        if (handle->conn_info & TCI_SYS_DEV)
        {
            (void)close(handle->dev_info.tpm_device);
        }
        else if (handle->conn_info & TCI_SOCKET)
        {
            close_simulator(handle);
            tpm_socket_destroy(handle->dev_info.socket_conn);
        }
        else if (handle->conn_info & TCI_TCTI)
        {
            TCTI_CTX *tcti_ctx = (TCTI_CTX*)handle->dev_info.tcti.ctx_handle;
            tcti_ctx->finalize(handle->dev_info.tcti.ctx_handle);
            dlclose(handle->dev_info.tcti.dylib);
        }
        free(handle);
    }
}