From 9f854fb85a6b6747c90f31c5816701dfdb8769a9 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Sun, 15 Jun 2014 15:46:22 +0000 Subject: Simplify EVP_MD_CTX_create() by just using calloc(). Also, use 0 rather than '\0' for several memset(). ok beck@ miod@ --- src/lib/libcrypto/evp/digest.c | 13 ++++--------- src/lib/libssl/src/crypto/evp/digest.c | 13 ++++--------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c index 4071d71e1e..f598e78911 100644 --- a/src/lib/libcrypto/evp/digest.c +++ b/src/lib/libcrypto/evp/digest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: digest.c,v 1.17 2014/06/12 15:49:29 deraadt Exp $ */ +/* $OpenBSD: digest.c,v 1.18 2014/06/15 15:46:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -120,18 +120,13 @@ void EVP_MD_CTX_init(EVP_MD_CTX *ctx) { - memset(ctx, '\0', sizeof *ctx); + memset(ctx, 0, sizeof *ctx); } EVP_MD_CTX * EVP_MD_CTX_create(void) { - EVP_MD_CTX *ctx = malloc(sizeof *ctx); - - if (ctx) - EVP_MD_CTX_init(ctx); - - return ctx; + return calloc(1, sizeof(EVP_MD_CTX)); } int @@ -367,7 +362,7 @@ EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) * functional reference we held for this reason. */ ENGINE_finish(ctx->engine); #endif - memset(ctx, '\0', sizeof *ctx); + memset(ctx, 0, sizeof *ctx); return 1; } diff --git a/src/lib/libssl/src/crypto/evp/digest.c b/src/lib/libssl/src/crypto/evp/digest.c index 4071d71e1e..f598e78911 100644 --- a/src/lib/libssl/src/crypto/evp/digest.c +++ b/src/lib/libssl/src/crypto/evp/digest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: digest.c,v 1.17 2014/06/12 15:49:29 deraadt Exp $ */ +/* $OpenBSD: digest.c,v 1.18 2014/06/15 15:46:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -120,18 +120,13 @@ void EVP_MD_CTX_init(EVP_MD_CTX *ctx) { - memset(ctx, '\0', sizeof *ctx); + memset(ctx, 0, sizeof *ctx); } EVP_MD_CTX * EVP_MD_CTX_create(void) { - EVP_MD_CTX *ctx = malloc(sizeof *ctx); - - if (ctx) - EVP_MD_CTX_init(ctx); - - return ctx; + return calloc(1, sizeof(EVP_MD_CTX)); } int @@ -367,7 +362,7 @@ EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) * functional reference we held for this reason. */ ENGINE_finish(ctx->engine); #endif - memset(ctx, '\0', sizeof *ctx); + memset(ctx, 0, sizeof *ctx); return 1; } -- cgit v1.2.3-55-g6feb