soc.2008.masterpassword: 0ed8cbef: Fix const-ness of strings, and silly str...

qulogic at pidgin.im qulogic at pidgin.im
Mon Nov 7 02:37:06 EST 2011


----------------------------------------------------------------------
Revision: 0ed8cbefec48778afa6bd6114812eb540a7e4931
Parent:   4c7422c71f98e7262dd9b279a19507b655f82d1a
Author:   qulogic at pidgin.im
Date:     11/05/11 22:23:32
Branch:   im.pidgin.soc.2008.masterpassword
URL: http://d.pidgin.im/viewmtn/revision/info/0ed8cbefec48778afa6bd6114812eb540a7e4931

Changelog: 

Fix const-ness of strings, and silly strdups.

Changes against parent 4c7422c71f98e7262dd9b279a19507b655f82d1a

  patched  libpurple/keyring.c
  patched  libpurple/keyring.h
  patched  libpurple/plugins/keyrings/gnomekeyring.c
  patched  libpurple/plugins/keyrings/internalkeyring.c

-------------- next part --------------
============================================================
--- libpurple/keyring.h	ac821b65b66f2a692172cd76a4c4aff8c88c6b8e
+++ libpurple/keyring.h	ecc82c4144c67a0f224627e5e864dc06f5a019a6
@@ -63,14 +63,12 @@ typedef struct _PurpleKeyring PurpleKeyr
  * should be NULL, and the error set.
  *
  * @param account  The account of which the password was asked.
- * @param password The password that was read. This should be freed when the
- *                 callback returns.
- * @param error    Error that could have occured. Must be freed by the calling
- *                 function.
+ * @param password The password that was read.
+ * @param error    Error that could have occured.
  * @param data     Data passed to the callback.
  */
 typedef void (*PurpleKeyringReadCallback)(PurpleAccount *account,
-                                          gchar *password,
+                                          const gchar *password,
                                           GError *error,
                                           gpointer data);
 
@@ -78,8 +76,7 @@ typedef void (*PurpleKeyringReadCallback
  * Callback for once a password has been stored. If there was a problem, the
  * error will be set.
  *
- * @param error   Error that could have occured. Must be freed by the calling
- *                function.
+ * @param error   Error that could have occured.
  * @param account The account for which the password was saved.
  * @param data    Data passed to the callback.
  */
@@ -133,11 +130,8 @@ typedef void (*PurpleKeyringRead)(Purple
  * Store a password in the keyring.
  *
  * @param account  The account for which the password is to be stored.
- * @param password The password to be stored. This password will be freed once
- *                 the function returns, so one must take care to make a copy if
- *                 they call other async functions later. If the password is
- *                 NULL, this means that the keyring should forget about that
- *                 password.
+ * @param password The password to be stored. If the password is NULL, this
+ *                 means that the keyring should forget about that password.
  * @param cb       A callback to be called once the password is saved.
  * @param data     A pointer to be passed to the callback
  */
@@ -171,10 +165,8 @@ typedef void (*PurpleKeyringChangeMaster
  * decrypt passwords.
  *
  * @param account The account.
- * @param mode    A keyring specific option that was stored. Can be NULL, will
- *                be freed when function returns.
- * @param data    Data that was stored, Can be NULL, will be freed when function
- *                returns (so copy it if you need it).
+ * @param mode    A keyring specific option that was stored. Can be NULL.
+ * @param data    Data that was stored. Can be NULL.
  *
  * @return TRUE on success, FALSE on failure.
  */
@@ -217,7 +209,7 @@ extern "C" {
 /*@{*/
 
 /**
- * Find a keyring from it's keyring id.
+ * Find a keyring from its keyring id.
  *
  * @param id The id for the keyring.
  *
@@ -403,8 +395,8 @@ PurpleKeyringExportPassword purple_keyri
 PurpleKeyringImportPassword purple_keyring_get_import_password(const PurpleKeyring *info);
 PurpleKeyringExportPassword purple_keyring_get_export_password(const PurpleKeyring *info);
 
-void purple_keyring_set_name(PurpleKeyring *info, char *name);
-void purple_keyring_set_id(PurpleKeyring *info, char *id);
+void purple_keyring_set_name(PurpleKeyring *info, const char *name);
+void purple_keyring_set_id(PurpleKeyring *info, const char *id);
 void purple_keyring_set_read_password(PurpleKeyring *info, PurpleKeyringRead read);
 void purple_keyring_set_save_password(PurpleKeyring *info, PurpleKeyringSave save);
 void purple_keyring_set_close_keyring(PurpleKeyring *info, PurpleKeyringClose close);
============================================================
--- libpurple/keyring.c	8d31849801e216e4a42badd4ec3c0a7dc0322f1e
+++ libpurple/keyring.c	c4ad3f1dce7169882b638b5cd5cf0de79c4caea0
@@ -154,7 +154,7 @@ void
 }
 
 void
-purple_keyring_set_name(PurpleKeyring *keyring, char *name)
+purple_keyring_set_name(PurpleKeyring *keyring, const char *name)
 {
 	g_return_if_fail(keyring != NULL);
 
@@ -163,7 +163,7 @@ void
 }
 
 void
-purple_keyring_set_id(PurpleKeyring *keyring, char *id)
+purple_keyring_set_id(PurpleKeyring *keyring, const char *id)
 {
 	g_return_if_fail(keyring != NULL);
 
@@ -301,7 +301,7 @@ static PurpleKeyring *
 }
 
 static PurpleKeyring *
-purple_keyring_find_keyring_by_id(char *id)
+purple_keyring_find_keyring_by_id(const char *id)
 {
 	GList *l;
 	PurpleKeyring *keyring;
@@ -355,7 +355,7 @@ purple_keyring_set_inuse_check_error_cb(
 {
 	const char *name;
 	PurpleKeyringClose close;
-	struct _PurpleKeyringChangeTracker *tracker;
+	PurpleKeyringChangeTracker *tracker;
 
 	tracker = (PurpleKeyringChangeTracker *)data;
 
============================================================
--- libpurple/plugins/keyrings/gnomekeyring.c	6d32bc2cc15989a4ef6cfe98d76310ae816b91fc
+++ libpurple/plugins/keyrings/gnomekeyring.c	b85dcf6b589a44fed7bdb6e7cd8d6094aecca8de
@@ -87,7 +87,6 @@ gkp_read_continue(GnomeKeyringResult res
 	PurpleAccount *account = storage->account;
 	PurpleKeyringReadCallback cb = storage->cb;
 	GError *error;
-	char *copy;
 
 	if (result != GNOME_KEYRING_RESULT_OK) {
 		switch(result) {
@@ -122,9 +121,7 @@ gkp_read_continue(GnomeKeyringResult res
 
 	} else {
 		if (cb != NULL) {
-			copy = g_strdup(password);
-			cb(account, copy, NULL, storage->user_data);
-			g_free(copy);
+			cb(account, password, NULL, storage->user_data);
 		}
 	}
 }
============================================================
--- libpurple/plugins/keyrings/internalkeyring.c	ece607a7d1bc91418b88a431300693ea21669b6f
+++ libpurple/plugins/keyrings/internalkeyring.c	6b0799045d0842d1a2bd47c0fcdadef9ead6ce01
@@ -78,7 +78,7 @@ internal_keyring_read(PurpleAccount *acc
                       PurpleKeyringReadCallback cb,
                       gpointer data)
 {
-	char *password;
+	const char *password;
 	GError *error;
 
 	ACTIVATE();


More information about the Commits mailing list