aboutsummaryrefslogtreecommitdiff
path: root/src/lib/crypto/krb/keyblocks.c
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2009-10-03 16:03:15 +0000
committerGreg Hudson <ghudson@mit.edu>2009-10-03 16:03:15 +0000
commit8025c33f6285b8773a927351c0b3503d878565f1 (patch)
treefe8100e32b4efb5b03a88e065d0bcbc88691c303 /src/lib/crypto/krb/keyblocks.c
parent0faf98575f91452efee9f4c8d100c83fa9971e46 (diff)
downloadkrb5-8025c33f6285b8773a927351c0b3503d878565f1.zip
krb5-8025c33f6285b8773a927351c0b3503d878565f1.tar.gz
krb5-8025c33f6285b8773a927351c0b3503d878565f1.tar.bz2
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
Diffstat (limited to 'src/lib/crypto/krb/keyblocks.c')
-rw-r--r--src/lib/crypto/krb/keyblocks.c29
1 files changed, 15 insertions, 14 deletions
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 <assert.h>
-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;
}
}