libpurple/purpleconversation.c

changeset 42767
8cf1d11b59c1
parent 42760
0c293ecd56c2
child 42773
2718698a94b9
--- a/libpurple/purpleconversation.c	Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purpleconversation.c	Mon May 13 23:28:20 2024 -0500
@@ -152,10 +152,7 @@
 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 @@
 {
 	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 @@
 {
 	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 @@
 {
 	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 @@
 {
 	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 @@
 {
 	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]);
 	}

mercurial