# HG changeset patch
# Node ID 274fde6ab3c2
# Parent  d823c3372e97
diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -184,11 +184,10 @@ purple_connection_set_display_name(Purpl
 
 	priv = purple_connection_get_instance_private(connection);
 
-	g_clear_pointer(&priv->display_name, g_free);
-	priv->display_name = g_strdup(name);
-
-	g_object_notify_by_pspec(G_OBJECT(connection),
-	                         properties[PROP_DISPLAY_NAME]);
+	if(g_set_str(&priv->display_name, name)) {
+		g_object_notify_by_pspec(G_OBJECT(connection),
+		                         properties[PROP_DISPLAY_NAME]);
+	}
 }
 
 PurpleConnectionState
@@ -482,10 +481,9 @@ purple_connection_set_id(PurpleConnectio
 
 	priv = purple_connection_get_instance_private(connection);
 
-	g_free(priv->id);
-	priv->id = g_strdup(id);
-
-	g_object_notify_by_pspec(G_OBJECT(connection), properties[PROP_ID]);
+	if(g_set_str(&priv->id, id)) {
+		g_object_notify_by_pspec(G_OBJECT(connection), properties[PROP_ID]);
+	}
 }
 
 static void
diff --git a/libpurple/image.c b/libpurple/image.c
--- a/libpurple/image.c
+++ b/libpurple/image.c
@@ -54,9 +54,7 @@ static void
 _purple_image_set_path(PurpleImage *image, const gchar *path) {
 	PurpleImagePrivate *priv = purple_image_get_instance_private(image);
 
-	g_free(priv->path);
-
-	priv->path = g_strdup(path);
+	g_set_str(&priv->path, path);
 }
 
 static void
@@ -456,8 +454,7 @@ purple_image_set_friendly_filename(Purpl
 		escaped = NULL;
 	}
 
-	g_free(priv->friendly_filename);
-	priv->friendly_filename = g_strdup(escaped);
+	g_set_str(&priv->friendly_filename, escaped);
 }
 
 const gchar *
diff --git a/libpurple/prefs.c b/libpurple/prefs.c
--- a/libpurple/prefs.c
+++ b/libpurple/prefs.c
@@ -482,15 +482,10 @@ get_path_dirname(const char *name)
 		*c = '\0';
 
 		if (*str == '\0') {
-			g_free(str);
-
-			str = g_strdup("/");
+			g_set_str(&str, "/");
 		}
-	}
-	else {
-		g_free(str);
-
-		str = g_strdup(".");
+	} else {
+		g_set_str(&str, ".");
 	}
 
 	return str;
@@ -891,9 +886,7 @@ purple_prefs_set_string(const char *name
 			return;
 		}
 
-		if (!purple_strequal(pref->value.string, value)) {
-			g_free(pref->value.string);
-			pref->value.string = g_strdup(value);
+		if(g_set_str(&pref->value.string, value)) {
 			do_callbacks(name, pref);
 		}
 	} else {
@@ -951,9 +944,7 @@ purple_prefs_set_path(const char *name, 
 			return;
 		}
 
-		if (!purple_strequal(pref->value.string, value)) {
-			g_free(pref->value.string);
-			pref->value.string = g_strdup(value);
+		if(g_set_str(&pref->value.string, value)) {
 			do_callbacks(name, pref);
 		}
 	} else {
diff --git a/libpurple/purpleaccount.c b/libpurple/purpleaccount.c
--- a/libpurple/purpleaccount.c
+++ b/libpurple/purpleaccount.c
@@ -1215,25 +1215,24 @@ void
 purple_account_set_user_info(PurpleAccount *account, const char *user_info) {
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
-	g_free(account->user_info);
-	account->user_info = g_strdup(user_info);
+	if(g_set_str(&account->user_info, user_info)) {
+		g_object_notify_by_pspec(G_OBJECT(account),
+		                         properties[PROP_USER_INFO]);
 
-	g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_USER_INFO]);
-
-	purple_accounts_schedule_save();
+		purple_accounts_schedule_save();
+	}
 }
 
 void
 purple_account_set_buddy_icon_path(PurpleAccount *account, const char *path) {
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
-	g_free(account->buddy_icon_path);
-	account->buddy_icon_path = g_strdup(path);
+	if(g_set_str(&account->buddy_icon_path, path)) {
+		g_object_notify_by_pspec(G_OBJECT(account),
+		                         properties[PROP_BUDDY_ICON_PATH]);
 
-	g_object_notify_by_pspec(G_OBJECT(account),
-	                         properties[PROP_BUDDY_ICON_PATH]);
-
-	purple_accounts_schedule_save();
+		purple_accounts_schedule_save();
+	}
 }
 
 void
@@ -1242,12 +1241,12 @@ purple_account_set_protocol_id(PurpleAcc
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 	g_return_if_fail(protocol_id != NULL);
 
-	g_free(account->protocol_id);
-	account->protocol_id = g_strdup(protocol_id);
+	if(g_set_str(&account->protocol_id, protocol_id)) {
+		g_object_notify_by_pspec(G_OBJECT(account),
+		                         properties[PROP_PROTOCOL_ID]);
 
-	g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_PROTOCOL_ID]);
-
-	purple_accounts_schedule_save();
+		purple_accounts_schedule_save();
+	}
 }
 
 void
diff --git a/libpurple/purpleaccountoption.c b/libpurple/purpleaccountoption.c
--- a/libpurple/purpleaccountoption.c
+++ b/libpurple/purpleaccountoption.c
@@ -217,8 +217,7 @@ purple_account_option_set_default_string
 	g_return_if_fail(option != NULL);
 	g_return_if_fail(option->type == PURPLE_PREF_STRING);
 
-	g_free(option->default_value.string);
-	option->default_value.string = g_strdup(value);
+	g_set_str(&option->default_value.string, value);
 }
 
 void
diff --git a/libpurple/purpleaddcontactrequest.c b/libpurple/purpleaddcontactrequest.c
--- a/libpurple/purpleaddcontactrequest.c
+++ b/libpurple/purpleaddcontactrequest.c
@@ -75,10 +75,9 @@ purple_add_contact_request_set_username(
 {
 	g_return_if_fail(PURPLE_IS_ADD_CONTACT_REQUEST(request));
 
-	g_free(request->username);
-	request->username = g_strdup(username);
-
-	g_object_notify_by_pspec(G_OBJECT(request), properties[PROP_USERNAME]);
+	if(g_set_str(&request->username, username)) {
+		g_object_notify_by_pspec(G_OBJECT(request), properties[PROP_USERNAME]);
+	}
 }
 
 /******************************************************************************
@@ -289,10 +288,9 @@ purple_add_contact_request_set_alias(Pur
 {
 	g_return_if_fail(PURPLE_IS_ADD_CONTACT_REQUEST(request));
 
-	g_free(request->alias);
-	request->alias = g_strdup(alias);
-
-	g_object_notify_by_pspec(G_OBJECT(request), properties[PROP_ALIAS]);
+	if(g_set_str(&request->alias, alias)) {
+		g_object_notify_by_pspec(G_OBJECT(request), properties[PROP_ALIAS]);
+	}
 }
 
 const gchar *
@@ -308,10 +306,9 @@ purple_add_contact_request_set_message(P
 {
 	g_return_if_fail(PURPLE_IS_ADD_CONTACT_REQUEST(request));
 
-	g_free(request->message);
-	request->message = g_strdup(message);
-
-	g_object_notify_by_pspec(G_OBJECT(request), properties[PROP_MESSAGE]);
+	if(g_set_str(&request->message, message)) {
+		g_object_notify_by_pspec(G_OBJECT(request), properties[PROP_MESSAGE]);
+	}
 }
 
 const gchar *
diff --git a/libpurple/purpleattachment.c b/libpurple/purpleattachment.c
--- a/libpurple/purpleattachment.c
+++ b/libpurple/purpleattachment.c
@@ -56,16 +56,10 @@ static void
 purple_attachment_set_content_type(PurpleAttachment *attachment,
                                     const gchar *content_type)
 {
-	if(attachment->content_type == content_type) {
-		return;
+	if(g_set_str(&attachment->content_type, content_type)) {
+		g_object_notify_by_pspec(G_OBJECT(attachment),
+		                         properties[PROP_CONTENT_TYPE]);
 	}
-
-	g_clear_pointer(&attachment->content_type, g_free);
-
-	attachment->content_type = g_strdup(content_type);
-
-	g_object_notify_by_pspec(G_OBJECT(attachment),
-	                         properties[PROP_CONTENT_TYPE]);
 }
 
 /******************************************************************************
@@ -313,14 +307,10 @@ purple_attachment_set_remote_uri(PurpleA
 {
 	g_return_if_fail(PURPLE_IS_ATTACHMENT(attachment));
 
-	if(attachment->remote_uri == remote_uri) {
-		return;
+	if(g_set_str(&attachment->remote_uri, remote_uri)) {
+		g_object_notify_by_pspec(G_OBJECT(attachment),
+		                         properties[PROP_REMOTE_URI]);
 	}
-
-	g_free(attachment->remote_uri);
-	attachment->remote_uri = g_strdup(remote_uri);
-
-	g_object_notify_by_pspec(G_OBJECT(attachment), properties[PROP_REMOTE_URI]);
 }
 
 guint64
diff --git a/libpurple/purpleauthorizationrequest.c b/libpurple/purpleauthorizationrequest.c
--- a/libpurple/purpleauthorizationrequest.c
+++ b/libpurple/purpleauthorizationrequest.c
@@ -78,10 +78,9 @@ purple_authorization_request_set_usernam
 {
 	g_return_if_fail(PURPLE_IS_AUTHORIZATION_REQUEST(request));
 
-	g_free(request->username);
-	request->username = g_strdup(username);
-
-	g_object_notify_by_pspec(G_OBJECT(request), properties[PROP_USERNAME]);
+	if(g_set_str(&request->username, username)) {
+		g_object_notify_by_pspec(G_OBJECT(request), properties[PROP_USERNAME]);
+	}
 }
 
 /******************************************************************************
@@ -337,10 +336,9 @@ purple_authorization_request_set_alias(P
 {
 	g_return_if_fail(PURPLE_IS_AUTHORIZATION_REQUEST(request));
 
-	g_free(request->alias);
-	request->alias = g_strdup(alias);
-
-	g_object_notify_by_pspec(G_OBJECT(request), properties[PROP_ALIAS]);
+	if(g_set_str(&request->alias, alias)) {
+		g_object_notify_by_pspec(G_OBJECT(request), properties[PROP_ALIAS]);
+	}
 }
 
 const gchar *
@@ -356,10 +354,9 @@ purple_authorization_request_set_message
 {
 	g_return_if_fail(PURPLE_IS_AUTHORIZATION_REQUEST(request));
 
-	g_free(request->message);
-	request->message = g_strdup(message);
-
-	g_object_notify_by_pspec(G_OBJECT(request), properties[PROP_MESSAGE]);
+	if(g_set_str(&request->message, message)) {
+		g_object_notify_by_pspec(G_OBJECT(request), properties[PROP_MESSAGE]);
+	}
 }
 
 const gchar *
diff --git a/libpurple/purpleavatar.c b/libpurple/purpleavatar.c
--- a/libpurple/purpleavatar.c
+++ b/libpurple/purpleavatar.c
@@ -55,10 +55,9 @@ static void
 purple_avatar_set_filename(PurpleAvatar *avatar, const char *filename) {
 	g_return_if_fail(PURPLE_IS_AVATAR(avatar));
 
-	g_free(avatar->filename);
-	avatar->filename = g_strdup(filename);
-
-	g_object_notify_by_pspec(G_OBJECT(avatar), properties[PROP_FILENAME]);
+	if(g_set_str(&avatar->filename, filename)) {
+		g_object_notify_by_pspec(G_OBJECT(avatar), properties[PROP_FILENAME]);
+	}
 }
 
 static PurpleAvatar *
diff --git a/libpurple/purplechanneljoindetails.c b/libpurple/purplechanneljoindetails.c
--- a/libpurple/purplechanneljoindetails.c
+++ b/libpurple/purplechanneljoindetails.c
@@ -275,10 +275,7 @@ purple_channel_join_details_set_name(Pur
 {
 	g_return_if_fail(PURPLE_IS_CHANNEL_JOIN_DETAILS(details));
 
-	if(!purple_strequal(details->name, name)) {
-		g_free(details->name);
-		details->name = g_strdup(name);
-
+	if(g_set_str(&details->name, name)) {
 		g_object_notify_by_pspec(G_OBJECT(details), properties[PROP_NAME]);
 	}
 }
@@ -296,10 +293,7 @@ purple_channel_join_details_set_nickname
 {
 	g_return_if_fail(PURPLE_IS_CHANNEL_JOIN_DETAILS(details));
 
-	if(!purple_strequal(details->nickname, nickname)) {
-		g_free(details->nickname);
-		details->nickname = g_strdup(nickname);
-
+	if(g_set_str(&details->nickname, nickname)) {
 		g_object_notify_by_pspec(G_OBJECT(details), properties[PROP_NICKNAME]);
 	}
 }
@@ -324,10 +318,7 @@ purple_channel_join_details_set_password
 {
 	g_return_if_fail(PURPLE_IS_CHANNEL_JOIN_DETAILS(details));
 
-	if(!purple_strequal(details->password, password)) {
-		g_free(details->password);
-		details->password = g_strdup(password);
-
+	if(g_set_str(&details->password, password)) {
 		g_object_notify_by_pspec(G_OBJECT(details), properties[PROP_PASSWORD]);
 	}
 }
diff --git a/libpurple/purplecontactinfo.c b/libpurple/purplecontactinfo.c
--- a/libpurple/purplecontactinfo.c
+++ b/libpurple/purplecontactinfo.c
@@ -126,13 +126,7 @@ purple_contact_info_update_name_for_disp
 		name_for_display = priv->id;
 	}
 
-	if(!purple_strequal(name_for_display, priv->name_for_display)) {
-		/* If we have a new name for display, free the old one, dup the new one
-		 * into the struct, and then emit the notify signal.
-		 */
-		g_free(priv->name_for_display);
-		priv->name_for_display = g_strdup(name_for_display);
-
+	if(g_set_str(&priv->name_for_display, name_for_display)) {
 		g_object_notify_by_pspec(G_OBJECT(info),
 		                         properties[PROP_NAME_FOR_DISPLAY]);
 	}
@@ -702,18 +696,12 @@ purple_contact_info_get_id(PurpleContact
 void
 purple_contact_info_set_id(PurpleContactInfo *info, const gchar *id) {
 	PurpleContactInfoPrivate *priv = NULL;
-	gboolean changed = FALSE;
 
 	g_return_if_fail(PURPLE_IS_CONTACT_INFO(info));
 
 	priv = purple_contact_info_get_instance_private(info);
 
-	changed = !purple_strequal(priv->id, id);
-
-	g_free(priv->id);
-	priv->id = g_strdup(id);
-
-	if(changed) {
+	if(g_set_str(&priv->id, id)) {
 		g_object_freeze_notify(G_OBJECT(info));
 
 		g_object_notify_by_pspec(G_OBJECT(info), properties[PROP_ID]);
@@ -740,18 +728,12 @@ purple_contact_info_set_username(PurpleC
                                  const gchar *username)
 {
 	PurpleContactInfoPrivate *priv = NULL;
-	gboolean changed = FALSE;
 
 	g_return_if_fail(PURPLE_IS_CONTACT_INFO(info));
 
 	priv = purple_contact_info_get_instance_private(info);
 
-	changed = !purple_strequal(priv->username, username);
-
-	g_free(priv->username);
-	priv->username = g_strdup(username);
-
-	if(changed) {
+	if(g_set_str(&priv->username, username)) {
 		g_object_freeze_notify(G_OBJECT(info));
 
 		g_object_notify_by_pspec(G_OBJECT(info), properties[PROP_USERNAME]);
@@ -778,18 +760,12 @@ purple_contact_info_set_display_name(Pur
                                      const gchar *display_name)
 {
 	PurpleContactInfoPrivate *priv = NULL;
-	gboolean changed = FALSE;
 
 	g_return_if_fail(PURPLE_IS_CONTACT_INFO(info));
 
 	priv = purple_contact_info_get_instance_private(info);
 
-	changed = !purple_strequal(priv->display_name, display_name);
-
-	g_free(priv->display_name);
-	priv->display_name = g_strdup(display_name);
-
-	if(changed) {
+	if(g_set_str(&priv->display_name, display_name)) {
 		g_object_freeze_notify(G_OBJECT(info));
 
 		g_object_notify_by_pspec(G_OBJECT(info), properties[PROP_DISPLAY_NAME]);
@@ -814,18 +790,12 @@ purple_contact_info_get_alias(PurpleCont
 void
 purple_contact_info_set_alias(PurpleContactInfo *info, const gchar *alias) {
 	PurpleContactInfoPrivate *priv = NULL;
-	gboolean changed = FALSE;
 
 	g_return_if_fail(PURPLE_IS_CONTACT_INFO(info));
 
 	priv = purple_contact_info_get_instance_private(info);
 
-	changed = !purple_strequal(priv->alias, alias);
-
-	g_free(priv->alias);
-	priv->alias = g_strdup(alias);
-
-	if(changed) {
+	if(g_set_str(&priv->alias, alias)) {
 		g_object_freeze_notify(G_OBJECT(info));
 
 		g_object_notify_by_pspec(G_OBJECT(info), properties[PROP_ALIAS]);
@@ -855,10 +825,7 @@ purple_contact_info_set_color(PurpleCont
 
 	priv = purple_contact_info_get_instance_private(info);
 
-	if(!purple_strequal(priv->color, color)) {
-		g_free(priv->color);
-		priv->color = g_strdup(color);
-
+	if(g_set_str(&priv->color, color)) {
 		g_object_notify_by_pspec(G_OBJECT(info), properties[PROP_COLOR]);
 	}
 }
@@ -882,10 +849,7 @@ purple_contact_info_set_email(PurpleCont
 
 	priv = purple_contact_info_get_instance_private(info);
 
-	if(!purple_strequal(priv->email, email)) {
-		g_free(priv->email);
-		priv->email = g_strdup(email);
-
+	if(g_set_str(&priv->email, email)) {
 		g_object_notify_by_pspec(G_OBJECT(info), properties[PROP_EMAIL]);
 	}
 }
@@ -911,10 +875,7 @@ purple_contact_info_set_phone_number(Pur
 
 	priv = purple_contact_info_get_instance_private(info);
 
-	if(!purple_strequal(priv->phone_number, phone_number)) {
-		g_free(priv->phone_number);
-		priv->phone_number = g_strdup(phone_number);
-
+	if(g_set_str(&priv->phone_number, phone_number)) {
 		g_object_notify_by_pspec(G_OBJECT(info),
 		                         properties[PROP_PHONE_NUMBER]);
 	}
@@ -974,10 +935,7 @@ purple_contact_info_set_note(PurpleConta
 
 	priv = purple_contact_info_get_instance_private(info);
 
-	if(!purple_strequal(priv->note, note)) {
-		g_free(priv->note);
-		priv->note = g_strdup(note);
-
+	if(g_set_str(&priv->note, note)) {
 		g_object_notify_by_pspec(G_OBJECT(info), properties[PROP_NOTE]);
 	}
 }
@@ -1117,10 +1075,7 @@ purple_contact_info_set_sid(PurpleContac
 
 	priv = purple_contact_info_get_instance_private(info);
 
-	if(!purple_strequal(priv->sid, sid)) {
-		g_free(priv->sid);
-		priv->sid = g_strdup(sid);
-
+	if(g_set_str(&priv->sid, sid)) {
 		g_object_notify_by_pspec(G_OBJECT(info), properties[PROP_SID]);
 	}
 }
diff --git a/libpurple/purpleconversation.c b/libpurple/purpleconversation.c
--- a/libpurple/purpleconversation.c
+++ b/libpurple/purpleconversation.c
@@ -152,10 +152,7 @@ static void
 purple_conversation_set_id(PurpleConversation *conversation, const char *id) {
 	g_return_if_fail(PURPLE_IS_CONVERSATION(conversation));
 
-	if(!purple_strequal(id, conversation->id)) {
-		g_free(conversation->id);
-		conversation->id = g_strdup(id);
-
+	if(g_set_str(&conversation->id, id)) {
 		g_object_notify_by_pspec(G_OBJECT(conversation), properties[PROP_ID]);
 	}
 }
@@ -1211,12 +1208,9 @@ purple_conversation_set_title(PurpleConv
 {
 	g_return_if_fail(PURPLE_IS_CONVERSATION(conversation));
 
-	if(!purple_strequal(conversation->title, title)) {
+	if(g_set_str(&conversation->title, title)) {
 		GObject *obj = G_OBJECT(conversation);
 
-		g_free(conversation->title);
-		conversation->title = g_strdup(title);
-
 		/* We have to g_object_freeze_notify here because we're modifying more
 		 * than one property. However, purple_conversation_generate_title will
 		 * also have called g_object_freeze_notify before calling us because it
@@ -1321,10 +1315,7 @@ purple_conversation_set_name(PurpleConve
 {
 	g_return_if_fail(PURPLE_IS_CONVERSATION(conversation));
 
-	if(!purple_strequal(conversation->name, name)) {
-		g_free(conversation->name);
-		conversation->name = g_strdup(name);
-
+	if(g_set_str(&conversation->name, name)) {
 		g_object_notify_by_pspec(G_OBJECT(conversation),
 		                         properties[PROP_NAME]);
 	}
@@ -1521,10 +1512,7 @@ purple_conversation_set_description(Purp
 {
 	g_return_if_fail(PURPLE_IS_CONVERSATION(conversation));
 
-	if(!purple_strequal(conversation->description, description)) {
-		g_free(conversation->description);
-		conversation->description = g_strdup(description);
-
+	if(g_set_str(&conversation->description, description)) {
 		g_object_notify_by_pspec(G_OBJECT(conversation),
 		                         properties[PROP_DESCRIPTION]);
 	}
@@ -1543,10 +1531,7 @@ purple_conversation_set_topic(PurpleConv
 {
 	g_return_if_fail(PURPLE_IS_CONVERSATION(conversation));
 
-	if(!purple_strequal(conversation->topic, topic)) {
-		g_free(conversation->topic);
-		conversation->topic = g_strdup(topic);
-
+	if(g_set_str(&conversation->topic, topic)) {
 		g_object_notify_by_pspec(G_OBJECT(conversation),
 		                         properties[PROP_TOPIC]);
 	}
@@ -1624,10 +1609,7 @@ purple_conversation_set_user_nickname(Pu
 {
 	g_return_if_fail(PURPLE_IS_CONVERSATION(conversation));
 
-	if(!purple_strequal(conversation->user_nickname, nickname)) {
-		g_free(conversation->user_nickname);
-		conversation->user_nickname = g_strdup(nickname);
-
+	if(g_set_str(&conversation->user_nickname, nickname)) {
 		g_object_notify_by_pspec(G_OBJECT(conversation),
 		                         properties[PROP_USER_NICKNAME]);
 	}
diff --git a/libpurple/purplecredentialprovider.c b/libpurple/purplecredentialprovider.c
--- a/libpurple/purplecredentialprovider.c
+++ b/libpurple/purplecredentialprovider.c
@@ -56,10 +56,9 @@ purple_credential_provider_set_id(Purple
 
 	priv = purple_credential_provider_get_instance_private(provider);
 
-	g_free(priv->id);
-	priv->id = g_strdup(id);
-
-	g_object_notify_by_pspec(G_OBJECT(provider), properties[PROP_ID]);
+	if(g_set_str(&priv->id, id)) {
+		g_object_notify_by_pspec(G_OBJECT(provider), properties[PROP_ID]);
+	}
 }
 
 static void
@@ -70,10 +69,9 @@ purple_credential_provider_set_name(Purp
 
 	priv = purple_credential_provider_get_instance_private(provider);
 
-	g_free(priv->name);
-	priv->name = g_strdup(name);
-
-	g_object_notify_by_pspec(G_OBJECT(provider), properties[PROP_NAME]);
+	if(g_set_str(&priv->name, name)) {
+		g_object_notify_by_pspec(G_OBJECT(provider), properties[PROP_NAME]);
+	}
 }
 
 static void
@@ -84,10 +82,9 @@ purple_credential_provider_set_descripti
 
 	priv = purple_credential_provider_get_instance_private(provider);
 
-	g_free(priv->description);
-	priv->description = g_strdup(description);
-
-	g_object_notify_by_pspec(G_OBJECT(provider), properties[PROP_DESCRIPTION]);
+	if(g_set_str(&priv->description, description)) {
+		g_object_notify_by_pspec(G_OBJECT(provider), properties[PROP_DESCRIPTION]);
+	}
 }
 
 static void
diff --git a/libpurple/purplefiletransfer.c b/libpurple/purplefiletransfer.c
--- a/libpurple/purplefiletransfer.c
+++ b/libpurple/purplefiletransfer.c
@@ -110,10 +110,7 @@ purple_file_transfer_set_filename(Purple
 	g_return_if_fail(PURPLE_IS_FILE_TRANSFER(transfer));
 	g_return_if_fail(!purple_strempty(filename));
 
-	if(!purple_strequal(transfer->filename, filename)) {
-		g_free(transfer->filename);
-		transfer->filename = g_strdup(filename);
-
+	if(g_set_str(&transfer->filename, filename)) {
 		g_object_notify_by_pspec(G_OBJECT(transfer),
 		                         properties[PROP_FILENAME]);
 	}
@@ -653,10 +650,7 @@ purple_file_transfer_set_content_type(Pu
 {
 	g_return_if_fail(PURPLE_IS_FILE_TRANSFER(transfer));
 
-	if(!purple_strequal(transfer->content_type, content_type)) {
-		g_free(transfer->content_type);
-		transfer->content_type = g_strdup(content_type);
-
+	if(g_set_str(&transfer->content_type, content_type)) {
 		g_object_notify_by_pspec(G_OBJECT(transfer),
 		                         properties[PROP_CONTENT_TYPE]);
 	}
@@ -675,10 +669,7 @@ purple_file_transfer_set_message(PurpleF
 {
 	g_return_if_fail(PURPLE_IS_FILE_TRANSFER(transfer));
 
-	if(!purple_strequal(transfer->message, message)) {
-		g_free(transfer->message);
-		transfer->message = g_strdup(message);
-
+	if(g_set_str(&transfer->message, message)) {
 		g_object_notify_by_pspec(G_OBJECT(transfer), properties[PROP_MESSAGE]);
 	}
 }
diff --git a/libpurple/purplehistoryadapter.c b/libpurple/purplehistoryadapter.c
--- a/libpurple/purplehistoryadapter.c
+++ b/libpurple/purplehistoryadapter.c
@@ -49,10 +49,9 @@ purple_history_adapter_set_id(PurpleHist
 
 	priv = purple_history_adapter_get_instance_private(adapter);
 
-	g_free(priv->id);
-	priv->id = g_strdup(id);
-
-	g_object_notify_by_pspec(G_OBJECT(adapter), properties[PROP_ID]);
+	if(g_set_str(&priv->id, id)) {
+		g_object_notify_by_pspec(G_OBJECT(adapter), properties[PROP_ID]);
+	}
 }
 
 static void
@@ -63,10 +62,9 @@ purple_history_adapter_set_name(PurpleHi
 
 	priv = purple_history_adapter_get_instance_private(adapter);
 
-	g_free(priv->name);
-	priv->name = g_strdup(name);
-
-	g_object_notify_by_pspec(G_OBJECT(adapter), properties[PROP_NAME]);
+	if(g_set_str(&priv->name, name)) {
+		g_object_notify_by_pspec(G_OBJECT(adapter), properties[PROP_NAME]);
+	}
 }
 
 /******************************************************************************
diff --git a/libpurple/purpleidlemanager.c b/libpurple/purpleidlemanager.c
--- a/libpurple/purpleidlemanager.c
+++ b/libpurple/purpleidlemanager.c
@@ -158,15 +158,11 @@ purple_idle_manager_set_source(PurpleIdl
 		}
 	}
 
-	/* Finally check if new_source matches old source. */
-	if(!purple_strequal(new_source, manager->active_source)) {
-		/* We have to set the active source before emitting the property change
-		 * otherwise purple_idle_manager_get_timestamp will look up the wrong
-		 * value.
-		 */
-		g_free(manager->active_source);
-		manager->active_source = g_strdup(new_source);
-
+	/* We have to set the active source before emitting the property change
+	 * otherwise purple_idle_manager_get_timestamp will look up the wrong
+	 * value.
+	 */
+	if(g_set_str(&manager->active_source, new_source)) {
 		g_object_notify_by_pspec(G_OBJECT(manager),
 		                         properties[PROP_TIMESTAMP]);
 
diff --git a/libpurple/purplemessage.c b/libpurple/purplemessage.c
--- a/libpurple/purplemessage.c
+++ b/libpurple/purplemessage.c
@@ -75,10 +75,9 @@ G_DEFINE_FINAL_TYPE(PurpleMessage, purpl
  *****************************************************************************/
 static void
 purple_message_set_author(PurpleMessage *message, const char *author) {
-	g_free(message->author);
-	message->author = g_strdup(author);
-
-	g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_AUTHOR]);
+	if(g_set_str(&message->author, author)) {
+		g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_AUTHOR]);
+	}
 }
 
 /******************************************************************************
@@ -507,10 +506,9 @@ void
 purple_message_set_id(PurpleMessage *message, const char *id) {
 	g_return_if_fail(PURPLE_IS_MESSAGE(message));
 
-	g_free(message->id);
-	message->id = g_strdup(id);
-
-	g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_ID]);
+	if(g_set_str(&message->id, id)) {
+		g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_ID]);
+	}
 }
 
 const char *
@@ -526,11 +524,10 @@ purple_message_set_author_name_color(Pur
 {
 	g_return_if_fail(PURPLE_IS_MESSAGE(message));
 
-	g_free(message->author_name_color);
-	message->author_name_color = g_strdup(color);
-
-	g_object_notify_by_pspec(G_OBJECT(message),
-	                         properties[PROP_AUTHOR_NAME_COLOR]);
+	if(g_set_str(&message->author_name_color, color)) {
+		g_object_notify_by_pspec(G_OBJECT(message),
+		                         properties[PROP_AUTHOR_NAME_COLOR]);
+	}
 }
 
 const char *
@@ -546,10 +543,10 @@ purple_message_set_author_alias(PurpleMe
 {
 	g_return_if_fail(PURPLE_IS_MESSAGE(message));
 
-	g_free(message->author_alias);
-	message->author_alias = g_strdup(author_alias);
-
-	g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_AUTHOR_ALIAS]);
+	if(g_set_str(&message->author_alias, author_alias)) {
+		g_object_notify_by_pspec(G_OBJECT(message),
+		                         properties[PROP_AUTHOR_ALIAS]);
+	}
 }
 
 const char *
@@ -566,10 +563,9 @@ void
 purple_message_set_contents(PurpleMessage *message, const char *contents) {
 	g_return_if_fail(PURPLE_IS_MESSAGE(message));
 
-	g_free(message->contents);
-	message->contents = g_strdup(contents);
-
-	g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_CONTENTS]);
+	if(g_set_str(&message->contents, contents)) {
+		g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_CONTENTS]);
+	}
 }
 
 const char *
diff --git a/libpurple/purplenotification.c b/libpurple/purplenotification.c
--- a/libpurple/purplenotification.c
+++ b/libpurple/purplenotification.c
@@ -699,10 +699,7 @@ purple_notification_set_title(PurpleNoti
 
 	priv = purple_notification_get_instance_private(notification);
 
-	if(!purple_strequal(priv->title, title)) {
-		g_free(priv->title);
-		priv->title = g_strdup(title);
-
+	if(g_set_str(&priv->title, title)) {
 		g_object_notify_by_pspec(G_OBJECT(notification),
 		                         properties[PROP_TITLE]);
 	}
@@ -729,10 +726,7 @@ purple_notification_set_subtitle(PurpleN
 
 	priv = purple_notification_get_instance_private(notification);
 
-	if(!purple_strequal(priv->subtitle, subtitle)) {
-		g_free(priv->subtitle);
-		priv->subtitle = g_strdup(subtitle);
-
+	if(g_set_str(&priv->subtitle, subtitle)) {
 		g_object_notify_by_pspec(G_OBJECT(notification),
 		                         properties[PROP_SUBTITLE]);
 	}
@@ -759,10 +753,7 @@ purple_notification_set_icon_name(Purple
 
 	priv = purple_notification_get_instance_private(notification);
 
-	if(!purple_strequal(priv->icon_name, icon_name)) {
-		g_free(priv->icon_name);
-		priv->icon_name = g_strdup(icon_name);
-
+	if(g_set_str(&priv->icon_name, icon_name)) {
 		g_object_notify_by_pspec(G_OBJECT(notification),
 		                         properties[PROP_ICON_NAME]);
 	}
diff --git a/libpurple/purplepath.c b/libpurple/purplepath.c
--- a/libpurple/purplepath.c
+++ b/libpurple/purplepath.c
@@ -84,11 +84,10 @@ purple_data_dir(void) {
 
 void
 purple_util_set_user_dir(const gchar *dir) {
-	g_free(custom_user_dir);
-	custom_user_dir = g_strdup(dir);
-
-	g_clear_pointer(&user_dir, g_free);
-	g_clear_pointer(&cache_dir, g_free);
-	g_clear_pointer(&config_dir, g_free);
-	g_clear_pointer(&data_dir, g_free);
+	if(g_set_str(&custom_user_dir, dir)) {
+		g_clear_pointer(&user_dir, g_free);
+		g_clear_pointer(&cache_dir, g_free);
+		g_clear_pointer(&config_dir, g_free);
+		g_clear_pointer(&data_dir, g_free);
+	}
 }
diff --git a/libpurple/purpleperson.c b/libpurple/purpleperson.c
--- a/libpurple/purpleperson.c
+++ b/libpurple/purpleperson.c
@@ -572,12 +572,9 @@ void
 purple_person_set_alias(PurplePerson *person, const char *alias) {
 	g_return_if_fail(PURPLE_IS_PERSON(person));
 
-	if(!purple_strequal(person->alias, alias)) {
+	if(g_set_str(&person->alias, alias)) {
 		GObject *obj = G_OBJECT(person);
 
-		g_free(person->alias);
-		person->alias = g_strdup(alias);
-
 		g_object_freeze_notify(obj);
 		g_object_notify_by_pspec(obj, properties[PROP_ALIAS]);
 		g_object_notify_by_pspec(obj, properties[PROP_NAME_FOR_DISPLAY]);
@@ -635,12 +632,9 @@ void
 purple_person_set_color(PurplePerson *person, const char *color) {
 	g_return_if_fail(PURPLE_IS_PERSON(person));
 
-	if(!purple_strequal(person->color, color)) {
+	if(g_set_str(&person->color, color)) {
 		GObject *obj = G_OBJECT(person);
 
-		g_free(person->color);
-		person->color = g_strdup(color);
-
 		g_object_freeze_notify(obj);
 		g_object_notify_by_pspec(obj, properties[PROP_COLOR]);
 		g_object_notify_by_pspec(obj, properties[PROP_COLOR_FOR_DISPLAY]);
diff --git a/libpurple/purplepresence.c b/libpurple/purplepresence.c
--- a/libpurple/purplepresence.c
+++ b/libpurple/purplepresence.c
@@ -461,10 +461,7 @@ void
 purple_presence_set_message(PurplePresence *presence, const char *message) {
 	g_return_if_fail(PURPLE_IS_PRESENCE(presence));
 
-	if(!purple_strequal(presence->message, message)) {
-		g_free(presence->message);
-		presence->message = g_strdup(message);
-
+	if(g_set_str(&presence->message, message)) {
 		g_object_notify_by_pspec(G_OBJECT(presence), properties[PROP_MESSAGE]);
 	}
 }
@@ -480,10 +477,7 @@ void
 purple_presence_set_emoji(PurplePresence *presence, const char *emoji) {
 	g_return_if_fail(PURPLE_IS_PRESENCE(presence));
 
-	if(!purple_strequal(presence->emoji, emoji)) {
-		g_free(presence->emoji);
-		presence->emoji = g_strdup(emoji);
-
+	if(g_set_str(&presence->emoji, emoji)) {
 		g_object_notify_by_pspec(G_OBJECT(presence), properties[PROP_EMOJI]);
 	}
 }
diff --git a/libpurple/purplepresencemanager.c b/libpurple/purplepresencemanager.c
--- a/libpurple/purplepresencemanager.c
+++ b/libpurple/purplepresencemanager.c
@@ -172,10 +172,7 @@ purple_presence_manager_set_path(PurpleP
 {
 	g_return_if_fail(PURPLE_IS_PRESENCE_MANAGER(manager));
 
-	if(!purple_strequal(path, manager->path)) {
-		g_free(manager->path);
-		manager->path = g_strdup(path);
-
+	if(g_set_str(&manager->path, path)) {
 		g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_PATH]);
 	}
 }
diff --git a/libpurple/purpleprotocol.c b/libpurple/purpleprotocol.c
--- a/libpurple/purpleprotocol.c
+++ b/libpurple/purpleprotocol.c
@@ -64,10 +64,10 @@ purple_protocol_set_id(PurpleProtocol *p
 	PurpleProtocolPrivate *priv = NULL;
 
 	priv = purple_protocol_get_instance_private(protocol);
-	g_free(priv->id);
-	priv->id = g_strdup(id);
 
-	g_object_notify_by_pspec(G_OBJECT(protocol), properties[PROP_ID]);
+	if(g_set_str(&priv->id, id)) {
+		g_object_notify_by_pspec(G_OBJECT(protocol), properties[PROP_ID]);
+	}
 }
 
 static void
@@ -75,10 +75,10 @@ purple_protocol_set_name(PurpleProtocol 
 	PurpleProtocolPrivate *priv = NULL;
 
 	priv = purple_protocol_get_instance_private(protocol);
-	g_free(priv->name);
-	priv->name = g_strdup(name);
 
-	g_object_notify_by_pspec(G_OBJECT(protocol), properties[PROP_NAME]);
+	if(g_set_str(&priv->name, name)) {
+		g_object_notify_by_pspec(G_OBJECT(protocol), properties[PROP_NAME]);
+	}
 }
 
 static void
@@ -86,10 +86,11 @@ purple_protocol_set_description(PurplePr
 	PurpleProtocolPrivate *priv = NULL;
 
 	priv = purple_protocol_get_instance_private(protocol);
-	g_free(priv->description);
-	priv->description = g_strdup(description);
 
-	g_object_notify_by_pspec(G_OBJECT(protocol), properties[PROP_DESCRIPTION]);
+	if(g_set_str(&priv->description, description)) {
+		g_object_notify_by_pspec(G_OBJECT(protocol),
+		                         properties[PROP_DESCRIPTION]);
+	}
 }
 
 static void
@@ -100,10 +101,10 @@ purple_protocol_set_icon_name(PurpleProt
 
 	priv = purple_protocol_get_instance_private(protocol);
 
-	g_free(priv->icon_name);
-	priv->icon_name = g_strdup(icon_name);
-
-	g_object_notify_by_pspec(G_OBJECT(protocol), properties[PROP_ICON_NAME]);
+	if(g_set_str(&priv->icon_name, icon_name)) {
+		g_object_notify_by_pspec(G_OBJECT(protocol),
+		                         properties[PROP_ICON_NAME]);
+	}
 }
 
 static void
@@ -114,11 +115,10 @@ purple_protocol_set_icon_search_path(Pur
 
 	priv = purple_protocol_get_instance_private(protocol);
 
-	g_free(priv->icon_search_path);
-	priv->icon_search_path = g_strdup(path);
-
-	g_object_notify_by_pspec(G_OBJECT(protocol),
-	                         properties[PROP_ICON_SEARCH_PATH]);
+	if(g_set_str(&priv->icon_search_path, path)) {
+		g_object_notify_by_pspec(G_OBJECT(protocol),
+		                         properties[PROP_ICON_SEARCH_PATH]);
+	}
 }
 
 static void
@@ -129,11 +129,10 @@ purple_protocol_set_icon_resource_path(P
 
 	priv = purple_protocol_get_instance_private(protocol);
 
-	g_free(priv->icon_resource_path);
-	priv->icon_resource_path = g_strdup(path);
-
-	g_object_notify_by_pspec(G_OBJECT(protocol),
-	                         properties[PROP_ICON_RESOURCE_PATH]);
+	if(g_set_str(&priv->icon_resource_path, path)) {
+		g_object_notify_by_pspec(G_OBJECT(protocol),
+		                         properties[PROP_ICON_RESOURCE_PATH]);
+	}
 }
 
 static void
diff --git a/libpurple/purpleproxyinfo.c b/libpurple/purpleproxyinfo.c
--- a/libpurple/purpleproxyinfo.c
+++ b/libpurple/purpleproxyinfo.c
@@ -229,10 +229,9 @@ void
 purple_proxy_info_set_hostname(PurpleProxyInfo *info, const gchar *hostname) {
     g_return_if_fail(PURPLE_IS_PROXY_INFO(info));
 
-    g_free(info->hostname);
-    info->hostname = g_strdup(hostname);
-
-    g_object_notify_by_pspec(G_OBJECT(info), properties[PROP_HOSTNAME]);
+    if(g_set_str(&info->hostname, hostname)) {
+		g_object_notify_by_pspec(G_OBJECT(info), properties[PROP_HOSTNAME]);
+	}
 }
 
 const gchar *
@@ -262,10 +261,9 @@ void
 purple_proxy_info_set_username(PurpleProxyInfo *info, const gchar *username) {
     g_return_if_fail(PURPLE_IS_PROXY_INFO(info));
 
-    g_free(info->username);
-    info->username = g_strdup(username);
-
-    g_object_notify_by_pspec(G_OBJECT(info), properties[PROP_USERNAME]);
+    if(g_set_str(&info->username, username)) {
+		g_object_notify_by_pspec(G_OBJECT(info), properties[PROP_USERNAME]);
+	}
 }
 
 const gchar *
@@ -279,10 +277,9 @@ void
 purple_proxy_info_set_password(PurpleProxyInfo *info, const gchar *password) {
     g_return_if_fail(PURPLE_IS_PROXY_INFO(info));
 
-    g_free(info->password);
-    info->password = g_strdup(password);
-
-    g_object_notify_by_pspec(G_OBJECT(info), properties[PROP_PASSWORD]);
+    if(g_set_str(&info->password, password)) {
+		g_object_notify_by_pspec(G_OBJECT(info), properties[PROP_PASSWORD]);
+	}
 }
 
 const gchar *
diff --git a/libpurple/purplesavedpresence.c b/libpurple/purplesavedpresence.c
--- a/libpurple/purplesavedpresence.c
+++ b/libpurple/purplesavedpresence.c
@@ -171,10 +171,7 @@ static void
 purple_saved_presence_set_id(PurpleSavedPresence *presence, const char *id) {
 	g_return_if_fail(PURPLE_IS_SAVED_PRESENCE(presence));
 
-	if(!purple_strequal(presence->id, id)) {
-		g_free(presence->id);
-		presence->id = g_strdup(id);
-
+	if(g_set_str(&presence->id, id)) {
 		g_object_notify_by_pspec(G_OBJECT(presence), properties[PROP_ID]);
 	}
 }
@@ -503,10 +500,7 @@ purple_saved_presence_set_name(PurpleSav
 {
 	g_return_if_fail(PURPLE_IS_SAVED_PRESENCE(presence));
 
-	if(!purple_strequal(presence->name, name)) {
-		g_free(presence->name);
-		presence->name = g_strdup(name);
-
+	if(g_set_str(&presence->name, name)) {
 		g_object_notify_by_pspec(G_OBJECT(presence), properties[PROP_NAME]);
 	}
 }
@@ -546,10 +540,7 @@ purple_saved_presence_set_message(Purple
 {
 	g_return_if_fail(PURPLE_IS_SAVED_PRESENCE(presence));
 
-	if(!purple_strequal(presence->message, message)) {
-		g_free(presence->message);
-		presence->message = g_strdup(message);
-
+	if(g_set_str(&presence->message, message)) {
 		g_object_notify_by_pspec(G_OBJECT(presence), properties[PROP_MESSAGE]);
 	}
 }
@@ -567,10 +558,7 @@ purple_saved_presence_set_emoji(PurpleSa
 {
 	g_return_if_fail(PURPLE_IS_SAVED_PRESENCE(presence));
 
-	if(!purple_strequal(presence->emoji, emoji)) {
-		g_free(presence->emoji);
-		presence->emoji = g_strdup(emoji);
-
+	if(g_set_str(&presence->emoji, emoji)) {
 		g_object_notify_by_pspec(G_OBJECT(presence), properties[PROP_EMOJI]);
 	}
 }
diff --git a/libpurple/purplesqlitehistoryadapter.c b/libpurple/purplesqlitehistoryadapter.c
--- a/libpurple/purplesqlitehistoryadapter.c
+++ b/libpurple/purplesqlitehistoryadapter.c
@@ -54,10 +54,9 @@ static void
 purple_sqlite_history_adapter_set_filename(PurpleSqliteHistoryAdapter *adapter,
                                            const gchar *filename)
 {
-	g_free(adapter->filename);
-	adapter->filename = g_strdup(filename);
-
-	g_object_notify_by_pspec(G_OBJECT(adapter), properties[PROP_FILENAME]);
+	if(g_set_str(&adapter->filename, filename)) {
+		g_object_notify_by_pspec(G_OBJECT(adapter), properties[PROP_FILENAME]);
+	}
 }
 
 static gboolean
diff --git a/libpurple/purpleui.c b/libpurple/purpleui.c
--- a/libpurple/purpleui.c
+++ b/libpurple/purpleui.c
@@ -56,10 +56,9 @@ purple_ui_set_id(PurpleUi *ui, const cha
 
 	priv = purple_ui_get_instance_private(ui);
 
-	g_free(priv->id);
-	priv->id = g_strdup(id);
-
-	g_object_notify_by_pspec(G_OBJECT(ui), properties[PROP_ID]);
+	if(g_set_str(&priv->id, id)) {
+		g_object_notify_by_pspec(G_OBJECT(ui), properties[PROP_ID]);
+	}
 }
 
 static void
@@ -70,10 +69,9 @@ purple_ui_set_name(PurpleUi *ui, const c
 
 	priv = purple_ui_get_instance_private(ui);
 
-	g_free(priv->name);
-	priv->name = g_strdup(name);
-
-	g_object_notify_by_pspec(G_OBJECT(ui), properties[PROP_NAME]);
+	if(g_set_str(&priv->name, name)) {
+		g_object_notify_by_pspec(G_OBJECT(ui), properties[PROP_NAME]);
+	}
 }
 
 static void
@@ -84,10 +82,9 @@ purple_ui_set_version(PurpleUi *ui, cons
 
 	priv = purple_ui_get_instance_private(ui);
 
-	g_free(priv->version);
-	priv->version = g_strdup(version);
-
-	g_object_notify_by_pspec(G_OBJECT(ui), properties[PROP_VERSION]);
+	if(g_set_str(&priv->version, version)) {
+		g_object_notify_by_pspec(G_OBJECT(ui), properties[PROP_VERSION]);
+	}
 }
 
 static void
@@ -98,10 +95,9 @@ purple_ui_set_website(PurpleUi *ui, cons
 
 	priv = purple_ui_get_instance_private(ui);
 
-	g_free(priv->website);
-	priv->website = g_strdup(website);
-
-	g_object_notify_by_pspec(G_OBJECT(ui), properties[PROP_WEBSITE]);
+	if(g_set_str(&priv->website, website)) {
+		g_object_notify_by_pspec(G_OBJECT(ui), properties[PROP_WEBSITE]);
+	}
 }
 
 static void
@@ -112,10 +108,10 @@ purple_ui_set_support_website(PurpleUi *
 
 	priv = purple_ui_get_instance_private(ui);
 
-	g_free(priv->support_website);
-	priv->support_website = g_strdup(support_website);
-
-	g_object_notify_by_pspec(G_OBJECT(ui), properties[PROP_SUPPORT_WEBSITE]);
+	if(g_set_str(&priv->support_website, support_website)) {
+		g_object_notify_by_pspec(G_OBJECT(ui),
+		                         properties[PROP_SUPPORT_WEBSITE]);
+	}
 }
 
 static void
@@ -126,10 +122,9 @@ purple_ui_set_client_type(PurpleUi *ui, 
 
 	priv = purple_ui_get_instance_private(ui);
 
-	g_free(priv->client_type);
-	priv->client_type = g_strdup(client_type);
-
-	g_object_notify_by_pspec(G_OBJECT(ui), properties[PROP_CLIENT_TYPE]);
+	if(g_set_str(&priv->client_type, client_type)) {
+		g_object_notify_by_pspec(G_OBJECT(ui), properties[PROP_CLIENT_TYPE]);
+	}
 }
 
 /******************************************************************************
diff --git a/libpurple/purplewhiteboard.c b/libpurple/purplewhiteboard.c
--- a/libpurple/purplewhiteboard.c
+++ b/libpurple/purplewhiteboard.c
@@ -77,10 +77,9 @@ purple_whiteboard_set_id(PurpleWhiteboar
 
 	priv = purple_whiteboard_get_instance_private(whiteboard);
 
-	g_free(priv->id);
-	priv->id = g_strdup(id);
-
-	g_object_notify_by_pspec(G_OBJECT(whiteboard), properties[PROP_ID]);
+	if(g_set_str(&priv->id, id)) {
+		g_object_notify_by_pspec(G_OBJECT(whiteboard), properties[PROP_ID]);
+	}
 }
 
 /******************************************************************************
diff --git a/libpurple/request/purplerequestfield.c b/libpurple/request/purplerequestfield.c
--- a/libpurple/request/purplerequestfield.c
+++ b/libpurple/request/purplerequestfield.c
@@ -66,10 +66,9 @@ purple_request_field_set_id(PurpleReques
 
 	priv = purple_request_field_get_instance_private(field);
 
-	g_free(priv->id);
-	priv->id = g_strdup(id);
-
-	g_object_notify_by_pspec(G_OBJECT(field), properties[PROP_ID]);
+	if(g_set_str(&priv->id, id)) {
+		g_object_notify_by_pspec(G_OBJECT(field), properties[PROP_ID]);
+	}
 }
 
 /******************************************************************************
@@ -324,10 +323,9 @@ purple_request_field_set_label(PurpleReq
 
 	priv = purple_request_field_get_instance_private(field);
 
-	g_free(priv->label);
-	priv->label = g_strdup(label);
-
-	g_object_notify_by_pspec(G_OBJECT(field), properties[PROP_LABEL]);
+	if(g_set_str(&priv->label, label)) {
+		g_object_notify_by_pspec(G_OBJECT(field), properties[PROP_LABEL]);
+	}
 }
 
 void
@@ -354,10 +352,9 @@ purple_request_field_set_type_hint(Purpl
 
 	priv = purple_request_field_get_instance_private(field);
 
-	g_free(priv->type_hint);
-	priv->type_hint = g_strdup(type_hint);
-
-	g_object_notify_by_pspec(G_OBJECT(field), properties[PROP_TYPE_HINT]);
+	if(g_set_str(&priv->type_hint, type_hint)) {
+		g_object_notify_by_pspec(G_OBJECT(field), properties[PROP_TYPE_HINT]);
+	}
 }
 
 void
@@ -369,10 +366,9 @@ purple_request_field_set_tooltip(PurpleR
 
 	priv = purple_request_field_get_instance_private(field);
 
-	g_free(priv->tooltip);
-	priv->tooltip = g_strdup(tooltip);
-
-	g_object_notify_by_pspec(G_OBJECT(field), properties[PROP_TOOLTIP]);
+	if(g_set_str(&priv->tooltip, tooltip)) {
+		g_object_notify_by_pspec(G_OBJECT(field), properties[PROP_TOOLTIP]);
+	}
 }
 
 void
diff --git a/libpurple/request/purplerequestfieldstring.c b/libpurple/request/purplerequestfieldstring.c
--- a/libpurple/request/purplerequestfieldstring.c
+++ b/libpurple/request/purplerequestfieldstring.c
@@ -238,10 +238,7 @@ purple_request_field_string_set_default_
 {
 	g_return_if_fail(PURPLE_IS_REQUEST_FIELD_STRING(field));
 
-	if(!purple_strequal(field->default_value, default_value)) {
-		g_free(field->default_value);
-		field->default_value = g_strdup(default_value);
-
+	if(g_set_str(&field->default_value, default_value)) {
 		g_object_notify_by_pspec(G_OBJECT(field),
 		                         properties[PROP_DEFAULT_VALUE]);
 	}
@@ -255,22 +252,18 @@ purple_request_field_string_set_value(Pu
 
 	g_return_if_fail(PURPLE_IS_REQUEST_FIELD_STRING(field));
 
-	if(purple_strequal(field->value, value)) {
-		return;
-	}
+	before = purple_request_field_string_is_filled(PURPLE_REQUEST_FIELD(field));
+	if(g_set_str(&field->value, value)) {
+		after = purple_request_field_string_is_filled(PURPLE_REQUEST_FIELD(field));
 
-	before = purple_request_field_string_is_filled(PURPLE_REQUEST_FIELD(field));
-	g_free(field->value);
-	field->value = g_strdup(value);
-	after = purple_request_field_string_is_filled(PURPLE_REQUEST_FIELD(field));
-
-	g_object_freeze_notify(G_OBJECT(field));
-	g_object_notify_by_pspec(G_OBJECT(field), properties[PROP_VALUE]);
-	g_object_notify(G_OBJECT(field), "valid");
-	if(before != after) {
-		g_object_notify(G_OBJECT(field), "filled");
+		g_object_freeze_notify(G_OBJECT(field));
+		g_object_notify_by_pspec(G_OBJECT(field), properties[PROP_VALUE]);
+		g_object_notify(G_OBJECT(field), "valid");
+		if(before != after) {
+			g_object_notify(G_OBJECT(field), "filled");
+		}
+		g_object_thaw_notify(G_OBJECT(field));
 	}
-	g_object_thaw_notify(G_OBJECT(field));
 }
 
 void
diff --git a/libpurple/request/purplerequestgroup.c b/libpurple/request/purplerequestgroup.c
--- a/libpurple/request/purplerequestgroup.c
+++ b/libpurple/request/purplerequestgroup.c
@@ -50,10 +50,9 @@ static GParamSpec *properties[N_PROPERTI
  *****************************************************************************/
 static void
 purple_request_group_set_title(PurpleRequestGroup *group, const char *title) {
-	g_free(group->title);
-	group->title = g_strdup(title);
-
-	g_object_notify_by_pspec(G_OBJECT(group), properties[PROP_TITLE]);
+	if(g_set_str(&group->title, title)) {
+		g_object_notify_by_pspec(G_OBJECT(group), properties[PROP_TITLE]);
+	}
 }
 
 /******************************************************************************
diff --git a/libpurple/xmlnode.c b/libpurple/xmlnode.c
--- a/libpurple/xmlnode.c
+++ b/libpurple/xmlnode.c
@@ -295,8 +295,7 @@ void purple_xmlnode_set_prefix(PurpleXml
 {
 	g_return_if_fail(node != NULL);
 
-	g_free(node->prefix);
-	node->prefix = g_strdup(prefix);
+	g_set_str(&node->prefix, prefix);
 }
 
 const char *purple_xmlnode_get_prefix(const PurpleXmlNode *node)
diff --git a/pidgin/pidginaccountfilterprotocol.c b/pidgin/pidginaccountfilterprotocol.c
--- a/pidgin/pidginaccountfilterprotocol.c
+++ b/pidgin/pidginaccountfilterprotocol.c
@@ -44,10 +44,9 @@ static void
 pidgin_account_filter_protocol_set_protocol_id(PidginAccountFilterProtocol *filter,
                                                const gchar *protocol_id)
 {
-	g_free(filter->protocol_id);
-	filter->protocol_id = g_strdup(protocol_id);
-
-	gtk_filter_changed(GTK_FILTER(filter), GTK_FILTER_CHANGE_DIFFERENT);
+	if(g_set_str(&filter->protocol_id, protocol_id)) {
+		gtk_filter_changed(GTK_FILTER(filter), GTK_FILTER_CHANGE_DIFFERENT);
+	}
 }
 
 /******************************************************************************
diff --git a/pidgin/pidgindisplayitem.c b/pidgin/pidgindisplayitem.c
--- a/pidgin/pidgindisplayitem.c
+++ b/pidgin/pidgindisplayitem.c
@@ -71,14 +71,9 @@ pidgin_display_item_set_id(PidginDisplay
 	g_return_if_fail(PIDGIN_IS_DISPLAY_ITEM(item));
 	g_return_if_fail(id != NULL);
 
-	if(item->id == id) {
-		return;
+	if(g_set_str(&item->id, id)) {
+		g_object_notify_by_pspec(G_OBJECT(item), properties[PROP_ID]);
 	}
-
-	g_free(item->id);
-	item->id = g_strdup(id);
-
-	g_object_notify_by_pspec(G_OBJECT(item), properties[PROP_ID]);
 }
 
 /******************************************************************************
@@ -327,14 +322,9 @@ void
 pidgin_display_item_set_title(PidginDisplayItem *item, const char *title) {
 	g_return_if_fail(PIDGIN_IS_DISPLAY_ITEM(item));
 
-	if(item->title == title) {
-		return;
+	if(g_set_str(&item->title, title)) {
+		g_object_notify_by_pspec(G_OBJECT(item), properties[PROP_TITLE]);
 	}
-
-	g_free(item->title);
-	item->title = g_strdup(title);
-
-	g_object_notify_by_pspec(G_OBJECT(item), properties[PROP_TITLE]);
 }
 
 const char *
@@ -350,14 +340,9 @@ pidgin_display_item_set_icon_name(Pidgin
 {
 	g_return_if_fail(PIDGIN_IS_DISPLAY_ITEM(item));
 
-	if(item->icon_name == icon_name) {
-		return;
+	if(g_set_str(&item->icon_name, icon_name)) {
+		g_object_notify_by_pspec(G_OBJECT(item), properties[PROP_ICON_NAME]);
 	}
-
-	g_free(item->icon_name);
-	item->icon_name = g_strdup(icon_name);
-
-	g_object_notify_by_pspec(G_OBJECT(item), properties[PROP_ICON_NAME]);
 }
 
 gboolean
diff --git a/pidgin/pidgininfopane.c b/pidgin/pidgininfopane.c
--- a/pidgin/pidgininfopane.c
+++ b/pidgin/pidgininfopane.c
@@ -197,10 +197,7 @@ void
 pidgin_info_pane_set_title(PidginInfoPane *pane, const char *title) {
 	g_return_if_fail(PIDGIN_IS_INFO_PANE(pane));
 
-	if(!purple_strequal(pane->title, title)) {
-		g_free(pane->title);
-		pane->title = g_strdup(title);
-
+	if(g_set_str(&pane->title, title)) {
 		g_object_notify_by_pspec(G_OBJECT(pane), properties[PROP_TITLE]);
 	}
 }
@@ -216,10 +213,7 @@ void
 pidgin_info_pane_set_subtitle(PidginInfoPane *pane, const char *subtitle) {
 	g_return_if_fail(PIDGIN_IS_INFO_PANE(pane));
 
-	if(!purple_strequal(pane->subtitle, subtitle)) {
-		g_free(pane->subtitle);
-		pane->subtitle = g_strdup(subtitle);
-
+	if(g_set_str(&pane->subtitle, subtitle)) {
 		g_object_notify_by_pspec(G_OBJECT(pane), properties[PROP_SUBTITLE]);
 	}
 }
diff --git a/pidgin/pidginpresenceicon.c b/pidgin/pidginpresenceicon.c
--- a/pidgin/pidginpresenceicon.c
+++ b/pidgin/pidginpresenceicon.c
@@ -256,16 +256,15 @@ pidgin_presence_icon_set_fallback(Pidgin
 	g_return_if_fail(PIDGIN_IS_PRESENCE_ICON(icon));
 	g_return_if_fail(fallback != NULL);
 
-	g_free(icon->fallback);
-	icon->fallback = g_strdup(fallback);
+	if(g_set_str(&icon->fallback, fallback)) {
+		g_object_freeze_notify(G_OBJECT(icon));
 
-	g_object_freeze_notify(G_OBJECT(icon));
+		pidgin_presence_icon_update(icon);
 
-	pidgin_presence_icon_update(icon);
+		g_object_notify_by_pspec(G_OBJECT(icon), properties[PROP_FALLBACK]);
 
-	g_object_notify_by_pspec(G_OBJECT(icon), properties[PROP_FALLBACK]);
-
-	g_object_thaw_notify(G_OBJECT(icon));
+		g_object_thaw_notify(G_OBJECT(icon));
+	}
 }
 
 GtkIconSize
diff --git a/pidgin/plugins/disco/xmppdiscoservice.c b/pidgin/plugins/disco/xmppdiscoservice.c
--- a/pidgin/plugins/disco/xmppdiscoservice.c
+++ b/pidgin/plugins/disco/xmppdiscoservice.c
@@ -322,10 +322,9 @@ void
 xmpp_disco_service_set_name(XmppDiscoService *service, const char *name) {
 	g_return_if_fail(XMPP_DISCO_IS_SERVICE(service));
 
-	g_free(service->name);
-	service->name = g_strdup(name);
-
-	g_object_notify_by_pspec(G_OBJECT(service), properties[PROP_NAME]);
+	if(g_set_str(&service->name, name)) {
+		g_object_notify_by_pspec(G_OBJECT(service), properties[PROP_NAME]);
+	}
 }
 
 const char *
@@ -341,10 +340,10 @@ xmpp_disco_service_set_description(XmppD
 {
 	g_return_if_fail(XMPP_DISCO_IS_SERVICE(service));
 
-	g_free(service->description);
-	service->description = g_strdup(description);
-
-	g_object_notify_by_pspec(G_OBJECT(service), properties[PROP_DESCRIPTION]);
+	if(g_set_str(&service->description, description)) {
+		g_object_notify_by_pspec(G_OBJECT(service),
+		                         properties[PROP_DESCRIPTION]);
+	}
 }
 
 XmppDiscoServiceType
@@ -382,17 +381,15 @@ void
 xmpp_disco_service_set_gateway_type(XmppDiscoService *service,
                                     const char *gateway_type)
 {
-	GObject *obj = NULL;
 	g_return_if_fail(XMPP_DISCO_IS_SERVICE(service));
 
-	g_free(service->gateway_type);
-	service->gateway_type = g_strdup(gateway_type);
-
-	obj = G_OBJECT(service);
-	g_object_freeze_notify(obj);
-	g_object_notify_by_pspec(obj, properties[PROP_GATEWAY_TYPE]);
-	g_object_notify_by_pspec(obj, properties[PROP_ICON_NAME]);
-	g_object_thaw_notify(obj);
+	if(g_set_str(&service->gateway_type, gateway_type)) {
+		GObject *obj = G_OBJECT(service);
+		g_object_freeze_notify(obj);
+		g_object_notify_by_pspec(obj, properties[PROP_GATEWAY_TYPE]);
+		g_object_notify_by_pspec(obj, properties[PROP_ICON_NAME]);
+		g_object_thaw_notify(obj);
+	}
 }
 
 XmppDiscoServiceFlags
@@ -446,10 +443,9 @@ void
 xmpp_disco_service_set_jid(XmppDiscoService *service, const char *jid) {
 	g_return_if_fail(XMPP_DISCO_IS_SERVICE(service));
 
-	g_free(service->jid);
-	service->jid = g_strdup(jid);
-
-	g_object_notify_by_pspec(G_OBJECT(service), properties[PROP_JID]);
+	if(g_set_str(&service->jid, jid)) {
+		g_object_notify_by_pspec(G_OBJECT(service), properties[PROP_JID]);
+	}
 }
 
 const char *
@@ -463,10 +459,9 @@ void
 xmpp_disco_service_set_node(XmppDiscoService *service, const char *node) {
 	g_return_if_fail(XMPP_DISCO_IS_SERVICE(service));
 
-	g_free(service->node);
-	service->node = g_strdup(node);
-
-	g_object_notify_by_pspec(G_OBJECT(service), properties[PROP_NODE]);
+	if(g_set_str(&service->node, node)) {
+		g_object_notify_by_pspec(G_OBJECT(service), properties[PROP_NODE]);
+	}
 }
 
 gboolean
diff --git a/protocols/ircv3/purpleircv3message.c b/protocols/ircv3/purpleircv3message.c
--- a/protocols/ircv3/purpleircv3message.c
+++ b/protocols/ircv3/purpleircv3message.c
@@ -210,10 +210,7 @@ purple_ircv3_message_set_command(PurpleI
 	g_return_if_fail(PURPLE_IRCV3_IS_MESSAGE(message));
 	g_return_if_fail(!purple_strempty(command));
 
-	if(!purple_strequal(message->command, command)) {
-		g_free(message->command);
-		message->command = g_strdup(command);
-
+	if(g_set_str(&message->command, command)) {
 		g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_COMMAND]);
 	}
 }
@@ -231,10 +228,7 @@ purple_ircv3_message_set_source(PurpleIR
 {
 	g_return_if_fail(PURPLE_IRCV3_IS_MESSAGE(message));
 
-	if(!purple_strequal(message->source, source)) {
-		g_free(message->source);
-		message->source = g_strdup(source);
-
+	if(g_set_str(&message->source, source)) {
 		g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_SOURCE]);
 	}
 }
