From 8025c33f6285b8773a927351c0b3503d878565f1 Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Sat, 3 Oct 2009 16:03:15 +0000 Subject: Update the crypto API glue to conform to most of the current coding practices (except lack of tabs). Use the helper functions k5alloc, zapfree, and find_enctype to reduce code size. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@22839 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/crypto/krb/keyblocks.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/lib/crypto/krb/keyblocks.c') diff --git a/src/lib/crypto/krb/keyblocks.c b/src/lib/crypto/krb/keyblocks.c index 5912c81..ee88f9a 100644 --- a/src/lib/crypto/krb/keyblocks.c +++ b/src/lib/crypto/krb/keyblocks.c @@ -33,29 +33,31 @@ #include "k5-int.h" #include -krb5_error_code krb5int_c_init_keyblock - (krb5_context context, krb5_enctype enctype, - size_t length, krb5_keyblock **out) +krb5_error_code +krb5int_c_init_keyblock(krb5_context context, krb5_enctype enctype, + size_t length, krb5_keyblock **out) { krb5_keyblock *kb; - kb = malloc (sizeof(krb5_keyblock)); - assert (out); + + assert(out); *out = NULL; - if (!kb) { + + kb = malloc(sizeof(krb5_keyblock)); + if (kb == NULL) return ENOMEM; - } kb->magic = KV5M_KEYBLOCK; kb->enctype = enctype; kb->length = length; - if(length) { - kb->contents = malloc (length); - if(!kb->contents) { - free (kb); + if (length) { + kb->contents = malloc(length); + if (!kb->contents) { + free(kb); return ENOMEM; } } else { kb->contents = NULL; } + *out = kb; return 0; } @@ -72,8 +74,7 @@ void krb5int_c_free_keyblock_contents(krb5_context context, krb5_keyblock *key) { if (key && key->contents) { - krb5int_zap_data (key->contents, key->length); - free(key->contents); - key->contents = 0; + zapfree(key->contents, key->length); + key->contents = NULL; } } -- cgit v1.1