1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-30 13:01:23 +03:00

Improve ssh_new().

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@331 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
Andreas Schneider
2009-04-01 21:27:54 +00:00
parent 891539af6c
commit 7b464d4e15

View File

@@ -40,23 +40,40 @@
* \returns new ssh_session pointer * \returns new ssh_session pointer
*/ */
SSH_SESSION *ssh_new(void) { SSH_SESSION *ssh_new(void) {
SSH_SESSION *session=malloc(sizeof (SSH_SESSION)); SSH_SESSION *session;
memset(session,0,sizeof(SSH_SESSION)); session = malloc(sizeof (SSH_SESSION));
if (session == NULL) {
return NULL;
}
ZERO_STRUCTP(session);
session->next_crypto = crypto_new(); session->next_crypto = crypto_new();
if (session->next_crypto == NULL) { if (session->next_crypto == NULL) {
goto err; goto err;
} }
session->maxchannel = FIRST_CHANNEL; session->maxchannel = FIRST_CHANNEL;
session->socket = ssh_socket_new(session); session->socket = ssh_socket_new(session);
if (session->socket == NULL) { if (session->socket == NULL) {
goto err; goto err;
} }
session->alive = 0; session->alive = 0;
session->auth_methods = 0; session->auth_methods = 0;
session->blocking = 1; session->blocking = 1;
session->log_indent = 0; session->log_indent = 0;
session->out_buffer = buffer_new(); session->out_buffer = buffer_new();
if (session->out_buffer == NULL) {
goto err;
}
session->in_buffer=buffer_new(); session->in_buffer=buffer_new();
if (session->in_buffer == NULL) {
goto err;
}
#ifndef _WIN32 #ifndef _WIN32
session->agent = agent_new(session); session->agent = agent_new(session);
if (session->agent == NULL) { if (session->agent == NULL) {