krb5 commit: Add zapfreedata() convenience function

Greg Hudson <[email protected]>
Newsgroups gmane.comp.encryption.kerberos.cvs
Message-ID <[email protected]>
https://github.com/krb5/krb5/commit/abd974cf867db5a398aa87ba9b9aaa34346e12a4
commit abd974cf867db5a398aa87ba9b9aaa34346e12a4
Author: Greg Hudson <[email protected]>
Date:   Thu Mar 14 11:26:44 2019 -0400

    Add zapfreedata() convenience function

 src/include/k5-int.h |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/include/k5-int.h b/src/include/k5-int.h
index 71dce73..f24e92c 100644
--- a/src/include/k5-int.h
+++ b/src/include/k5-int.h
@@ -666,6 +666,16 @@ zapfreestr(void *str)
     }
 }
 
+/* Convenience function: zap and free krb5_data pointer if it is non-NULL. */
+static inline void
+zapfreedata(krb5_data *data)
+{
+    if (data != NULL) {
+        zapfree(data->data, data->length);
+        free(data);
+    }
+}
+
 /*
  * Combine two keys (normally used by the hardware preauth mechanism)
  */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.