From b15a04e4636982c63720e2745dc0ac9ccd17df3f Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 17 Apr 2009 08:31:59 +0000 Subject: [PATCH] Improve sha1_init(). git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@515 7dcaeef0-15fb-0310-b436-a5af3365683c --- libssh/wrapper.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/libssh/wrapper.c b/libssh/wrapper.c index 46e2b232..82cddb7c 100644 --- a/libssh/wrapper.c +++ b/libssh/wrapper.c @@ -52,10 +52,11 @@ static int alloc_key(struct crypto_struct *cipher) { #ifdef HAVE_LIBGCRYPT #include -SHACTX sha1_init(){ - SHACTX ret; - gcry_md_open(&ret,GCRY_MD_SHA1,0); - return ret; +SHACTX sha1_init(void) { + SHACTX ctx = NULL; + gcry_md_open(&ctx, GCRY_MD_SHA1, 0); + + return ctx; } void sha1_update(SHACTX c, const void *data, unsigned long len){ gcry_md_write(c,data,len); @@ -249,13 +250,14 @@ static struct crypto_struct ssh_ciphertab[]={ #define OLD_CRYPTO #endif -SHACTX sha1_init(){ - SHACTX c = malloc(sizeof(*c)); - if (c == NULL) { - return NULL; - } - SHA1_Init(c); - return c; +SHACTX sha1_init(void) { + SHACTX ctx = malloc(sizeof(*c)); + if (c == NULL) { + return NULL; + } + SHA1_Init(c); + + return c; } void sha1_update(SHACTX c, const void *data, unsigned long len){ SHA1_Update(c,data,len);