From a14dec2bff2423c4fbb9db672ef91659bcdfb4ba Mon Sep 17 00:00:00 2001 From: Benjamin Kaduk Date: Mon, 2 Mar 2015 16:05:51 -0500 Subject: [PATCH] Make typedKey helpers more friendly to use Make freeing a NULL key pointer a no-op. Allow passing NULL to afsconf_typedKey_values() when not all values are needed. Change-Id: I3a4088747913e9e88be094da891cd2cca0cbb114 Reviewed-on: http://gerrit.openafs.org/11783 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- src/auth/keys.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/auth/keys.c b/src/auth/keys.c index 0ab3f2934..54ad95503 100644 --- a/src/auth/keys.c +++ b/src/auth/keys.c @@ -1057,6 +1057,8 @@ afsconf_typedKey_new(afsconf_keyType type, int kvno, int subType, void afsconf_typedKey_free(struct afsconf_typedKey **key) { + if (*key == NULL) + return; rx_opaque_freeContents(&(*key)->key); free(*key); *key = NULL; @@ -1082,10 +1084,14 @@ void afsconf_typedKey_values(struct afsconf_typedKey *key, afsconf_keyType *type, int *kvno, int *subType, struct rx_opaque **material) { - *type = key->type; - *kvno = key->kvno; - *subType = key->subType; - *material = &key->key; + if (type != NULL) + *type = key->type; + if (kvno != NULL) + *kvno = key->kvno; + if (subType != NULL) + *subType = key->subType; + if (material != NULL) + *material = &key->key; } int -- 2.39.5