From: Benjamin Kaduk Date: Mon, 2 Mar 2015 21:05:51 +0000 (-0500) Subject: Make typedKey helpers more friendly to use X-Git-Tag: upstream/1.8.0_pre1^2~186 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=a14dec2bff2423c4fbb9db672ef91659bcdfb4ba;p=packages%2Fo%2Fopenafs.git 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 --- 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