/soc/2013/ankitkv/gobjectification: dfeaa5c9c33a: Removed finali...

Ankit Vani a at nevitus.org
Sat Jun 15 13:24:16 EDT 2013


Changeset: dfeaa5c9c33a509b27f267b66e66151119c2f581
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-15 22:54 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/dfeaa5c9c33a

Description:

Removed finalize from PurpleCipher, and fixed appropriate finalize methods for ciphers that need it

diffstat:

 libpurple/cipher.c         |  18 ------------------
 libpurple/ciphers/hmac.c   |   2 ++
 libpurple/ciphers/pbkdf2.c |   6 ++++--
 3 files changed, 6 insertions(+), 20 deletions(-)

diffs (74 lines):

diff --git a/libpurple/cipher.c b/libpurple/cipher.c
--- a/libpurple/cipher.c
+++ b/libpurple/cipher.c
@@ -38,24 +38,10 @@
 #include "debug.h"
 
 /******************************************************************************
- * Globals
- *****************************************************************************/
-static GObjectClass *parent_class = NULL;
-
-/******************************************************************************
  * Object Stuff
  *****************************************************************************/
 static void
-purple_cipher_finalize(GObject *obj) {
-	purple_cipher_reset(PURPLE_CIPHER(obj));
-
-	G_OBJECT_CLASS(parent_class)->finalize(obj);
-}
-
-static void
 purple_cipher_class_init(PurpleCipherClass *klass) {
-	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
-
 	klass->reset = NULL;
 	klass->reset_state = NULL;
 	klass->set_iv = NULL;
@@ -72,10 +58,6 @@ purple_cipher_class_init(PurpleCipherCla
 	klass->get_batch_mode = NULL;
 	klass->get_block_size = NULL;
 	klass->get_name = NULL;
-
-	parent_class = g_type_class_peek_parent(klass);
-
-	obj_class->finalize = purple_cipher_finalize;
 }
 
 /******************************************************************************
diff --git a/libpurple/ciphers/hmac.c b/libpurple/ciphers/hmac.c
--- a/libpurple/ciphers/hmac.c
+++ b/libpurple/ciphers/hmac.c
@@ -263,6 +263,8 @@ purple_hmac_cipher_finalize(GObject *obj
 	PurpleCipher *cipher = PURPLE_CIPHER(obj);
 	PurpleHMACCipherPrivate *priv = PURPLE_HMAC_CIPHER_GET_PRIVATE(cipher);
 
+	purple_hmac_cipher_reset(cipher);
+
 	if (priv->hash != NULL)
 		g_object_unref(priv->hash);
 
diff --git a/libpurple/ciphers/pbkdf2.c b/libpurple/ciphers/pbkdf2.c
--- a/libpurple/ciphers/pbkdf2.c
+++ b/libpurple/ciphers/pbkdf2.c
@@ -85,8 +85,8 @@ purple_pbkdf2_cipher_reset(PurpleCipher 
 
 	g_return_if_fail(priv != NULL);
 
-	g_object_unref(priv->hash);
-	priv->hash = NULL;
+	if(PURPLE_IS_CIPHER(priv->hash))
+		purple_cipher_reset(priv->hash);
 	priv->iter_count = 1;
 	priv->out_len = 256;
 
@@ -316,6 +316,8 @@ purple_pbkdf2_cipher_finalize(GObject *o
 	PurpleCipher *cipher = PURPLE_CIPHER(obj);
 	PurplePBKDF2CipherPrivate *priv = PURPLE_PBKDF2_CIPHER_GET_PRIVATE(cipher);
 
+	purple_pbkdf2_cipher_reset(cipher);
+
 	if (priv->hash != NULL)
 		g_object_unref(priv->hash);
 



More information about the Commits mailing list