diff options
author | tb <> | 2020-09-25 11:05:21 +0000 |
---|---|---|
committer | tb <> | 2020-09-25 11:05:21 +0000 |
commit | da9b61085fa8c8f7e3937a53292f37ee69149488 (patch) | |
tree | 62c4f792dbcfaf173c7d23363be28044bdf54792 /src | |
parent | 6ba93d157a89d62d92a41e3dad8428d9d5876a6b (diff) | |
download | openbsd-da9b61085fa8c8f7e3937a53292f37ee69149488.tar.gz openbsd-da9b61085fa8c8f7e3937a53292f37ee69149488.tar.bz2 openbsd-da9b61085fa8c8f7e3937a53292f37ee69149488.zip |
Simplify UI_new_method()
Use calloc() instead of malloc() and setting all members manually to 0.
Avoid unnecessary else branch.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/ui/ui_lib.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c index 1e3a4ee705..0a22eba69f 100644 --- a/src/lib/libcrypto/ui/ui_lib.c +++ b/src/lib/libcrypto/ui/ui_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ui_lib.c,v 1.41 2020/09/25 10:56:36 tb Exp $ */ | 1 | /* $OpenBSD: ui_lib.c,v 1.42 2020/09/25 11:05:21 tb Exp $ */ |
2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL | 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL |
3 | * project 2001. | 3 | * project 2001. |
4 | */ | 4 | */ |
@@ -79,20 +79,14 @@ UI_new_method(const UI_METHOD *method) | |||
79 | { | 79 | { |
80 | UI *ret; | 80 | UI *ret; |
81 | 81 | ||
82 | ret = malloc(sizeof(UI)); | 82 | if ((ret = calloc(1, sizeof(UI))) == NULL) { |
83 | if (ret == NULL) { | ||
84 | UIerror(ERR_R_MALLOC_FAILURE); | 83 | UIerror(ERR_R_MALLOC_FAILURE); |
85 | return NULL; | 84 | return NULL; |
86 | } | 85 | } |
87 | if (method == NULL) | 86 | if ((ret->meth = method) == NULL) |
88 | ret->meth = UI_get_default_method(); | 87 | ret->meth = UI_get_default_method(); |
89 | else | ||
90 | ret->meth = method; | ||
91 | |||
92 | ret->strings = NULL; | ||
93 | ret->user_data = NULL; | ||
94 | ret->flags = 0; | ||
95 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_UI, ret, &ret->ex_data); | 88 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_UI, ret, &ret->ex_data); |
89 | |||
96 | return ret; | 90 | return ret; |
97 | } | 91 | } |
98 | 92 | ||