]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
crypto: define cleanup functions for use with g_autoptr
authorDaniel P. Berrangé <berrange@redhat.com>
Tue, 23 Jul 2019 14:29:40 +0000 (15:29 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 22 Aug 2019 09:47:12 +0000 (10:47 +0100)
Allow crypto structs to be used with g_autoptr, avoiding the need to
explicitly call XXX_free() functions when variables go out of scope on
the stack.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
include/crypto/block.h
include/crypto/cipher.h
include/crypto/hmac.h
include/crypto/ivgen.h
include/crypto/tlssession.h

index fe128998319c2806dd19dfd67a8668f521979b6f..d49d2c2da964cf51eec55b35eb522826a977a62a 100644 (file)
@@ -268,4 +268,6 @@ uint64_t qcrypto_block_get_sector_size(QCryptoBlock *block);
  */
 void qcrypto_block_free(QCryptoBlock *block);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(QCryptoBlock, qcrypto_block_free)
+
 #endif /* QCRYPTO_BLOCK_H */
index cac90b410c4d888f515e5813fe02760b874c8f35..5928e5ecc72e762cf5cb79e793b1cb423932eac1 100644 (file)
@@ -170,6 +170,8 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg,
  */
 void qcrypto_cipher_free(QCryptoCipher *cipher);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(QCryptoCipher, qcrypto_cipher_free)
+
 /**
  * qcrypto_cipher_encrypt:
  * @cipher: the cipher object
index aa3c97a2ffa163dfafd8dcd0b4909c0de421ba6a..ad4d7784161e744f3f51eac1d9fb4115a4317c90 100644 (file)
@@ -65,6 +65,8 @@ QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgorithm alg,
  */
 void qcrypto_hmac_free(QCryptoHmac *hmac);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(QCryptoHmac, qcrypto_hmac_free)
+
 /**
  * qcrypto_hmac_bytesv:
  * @hmac: the hmac object
index 9b4a62f7bb6fab285cfc6ac865f087f576d5577f..e41521519c727aa051c78ef64a408a6245eaa126 100644 (file)
@@ -203,4 +203,6 @@ QCryptoHashAlgorithm qcrypto_ivgen_get_hash(QCryptoIVGen *ivgen);
  */
 void qcrypto_ivgen_free(QCryptoIVGen *ivgen);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(QCryptoIVGen, qcrypto_ivgen_free)
+
 #endif /* QCRYPTO_IVGEN_H */
index 816300cdccb27a1664e7cbcb676eb8f8400cf29d..e01e1a9dc265dbd31b29cde341244f18bd47625a 100644 (file)
@@ -160,6 +160,8 @@ QCryptoTLSSession *qcrypto_tls_session_new(QCryptoTLSCreds *creds,
  */
 void qcrypto_tls_session_free(QCryptoTLSSession *sess);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(QCryptoTLSSession, qcrypto_tls_session_free)
+
 /**
  * qcrypto_tls_session_check_credentials:
  * @sess: the TLS session object