pidgin/pidgin

Use g_set_str everywhere

4 weeks ago, Elliott Sales de Andrade
8cf1d11b59c1
Parents d823c3372e97
Children 5ebb4beb29b7
Use g_set_str everywhere

This simplifies many setters.

Testing Done:
Ran `ninja turtles`

Reviewed at https://reviews.imfreedom.org/r/3182/
--- a/libpurple/connection.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/connection.c Mon May 13 23:28:20 2024 -0500
@@ -184,11 +184,10 @@
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 @@
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
--- a/libpurple/image.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/image.c Mon May 13 23:28:20 2024 -0500
@@ -54,9 +54,7 @@
_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 @@
escaped = NULL;
}
- g_free(priv->friendly_filename);
- priv->friendly_filename = g_strdup(escaped);
+ g_set_str(&priv->friendly_filename, escaped);
}
const gchar *
--- a/libpurple/prefs.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/prefs.c Mon May 13 23:28:20 2024 -0500
@@ -482,15 +482,10 @@
*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 @@
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 @@
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 {
--- a/libpurple/purpleaccount.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purpleaccount.c Mon May 13 23:28:20 2024 -0500
@@ -1215,25 +1215,24 @@
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 @@
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
--- a/libpurple/purpleaccountoption.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purpleaccountoption.c Mon May 13 23:28:20 2024 -0500
@@ -217,8 +217,7 @@
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
--- a/libpurple/purpleaddcontactrequest.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purpleaddcontactrequest.c Mon May 13 23:28:20 2024 -0500
@@ -75,10 +75,9 @@
{
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 @@
{
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 @@
{
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 *
--- a/libpurple/purpleattachment.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purpleattachment.c Mon May 13 23:28:20 2024 -0500
@@ -56,16 +56,10 @@
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 @@
{
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
--- a/libpurple/purpleauthorizationrequest.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purpleauthorizationrequest.c Mon May 13 23:28:20 2024 -0500
@@ -78,10 +78,9 @@
{
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 @@
{
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 @@
{
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 *
--- a/libpurple/purpleavatar.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purpleavatar.c Mon May 13 23:28:20 2024 -0500
@@ -55,10 +55,9 @@
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 *
--- a/libpurple/purplechanneljoindetails.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purplechanneljoindetails.c Mon May 13 23:28:20 2024 -0500
@@ -275,10 +275,7 @@
{
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 @@
{
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 @@
{
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]);
}
}
--- a/libpurple/purplecontactinfo.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purplecontactinfo.c Mon May 13 23:28:20 2024 -0500
@@ -126,13 +126,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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]);
}
}
--- 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]);
}
--- a/libpurple/purplecredentialprovider.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purplecredentialprovider.c Mon May 13 23:28:20 2024 -0500
@@ -56,10 +56,9 @@
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 @@
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 @@
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
--- a/libpurple/purplefiletransfer.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purplefiletransfer.c Mon May 13 23:28:20 2024 -0500
@@ -110,10 +110,7 @@
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 @@
{
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 @@
{
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]);
}
}
--- a/libpurple/purplehistoryadapter.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purplehistoryadapter.c Mon May 13 23:28:20 2024 -0500
@@ -49,10 +49,9 @@
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 @@
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]);
+ }
}
/******************************************************************************
--- a/libpurple/purpleidlemanager.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purpleidlemanager.c Mon May 13 23:28:20 2024 -0500
@@ -158,15 +158,11 @@
}
}
- /* 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]);
--- a/libpurple/purplemessage.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purplemessage.c Mon May 13 23:28:20 2024 -0500
@@ -75,10 +75,9 @@
*****************************************************************************/
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 @@
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 @@
{
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 @@
{
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 @@
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 *
--- a/libpurple/purplenotification.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purplenotification.c Mon May 13 23:28:20 2024 -0500
@@ -699,10 +699,7 @@
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 @@
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 @@
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]);
}
--- a/libpurple/purplepath.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purplepath.c Mon May 13 23:28:20 2024 -0500
@@ -84,11 +84,10 @@
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);
+ }
}
--- a/libpurple/purpleperson.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purpleperson.c Mon May 13 23:28:20 2024 -0500
@@ -572,12 +572,9 @@
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 @@
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]);
--- a/libpurple/purplepresence.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purplepresence.c Mon May 13 23:28:20 2024 -0500
@@ -461,10 +461,7 @@
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 @@
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]);
}
}
--- a/libpurple/purplepresencemanager.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purplepresencemanager.c Mon May 13 23:28:20 2024 -0500
@@ -172,10 +172,7 @@
{
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]);
}
}
--- a/libpurple/purpleprotocol.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purpleprotocol.c Mon May 13 23:28:20 2024 -0500
@@ -64,10 +64,10 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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
--- a/libpurple/purpleproxyinfo.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purpleproxyinfo.c Mon May 13 23:28:20 2024 -0500
@@ -229,10 +229,9 @@
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 @@
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 @@
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 *
--- a/libpurple/purplesavedpresence.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purplesavedpresence.c Mon May 13 23:28:20 2024 -0500
@@ -171,10 +171,7 @@
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 @@
{
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 @@
{
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 @@
{
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]);
}
}
--- a/libpurple/purplesqlitehistoryadapter.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purplesqlitehistoryadapter.c Mon May 13 23:28:20 2024 -0500
@@ -54,10 +54,9 @@
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
--- a/libpurple/purpleui.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purpleui.c Mon May 13 23:28:20 2024 -0500
@@ -56,10 +56,9 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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]);
+ }
}
/******************************************************************************
--- a/libpurple/purplewhiteboard.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/purplewhiteboard.c Mon May 13 23:28:20 2024 -0500
@@ -77,10 +77,9 @@
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]);
+ }
}
/******************************************************************************
--- a/libpurple/request/purplerequestfield.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/request/purplerequestfield.c Mon May 13 23:28:20 2024 -0500
@@ -66,10 +66,9 @@
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 @@
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 @@
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 @@
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
--- a/libpurple/request/purplerequestfieldstring.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/request/purplerequestfieldstring.c Mon May 13 23:28:20 2024 -0500
@@ -238,10 +238,7 @@
{
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 @@
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
--- a/libpurple/request/purplerequestgroup.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/request/purplerequestgroup.c Mon May 13 23:28:20 2024 -0500
@@ -50,10 +50,9 @@
*****************************************************************************/
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]);
+ }
}
/******************************************************************************
--- a/libpurple/xmlnode.c Fri May 10 01:10:09 2024 -0500
+++ b/libpurple/xmlnode.c Mon May 13 23:28:20 2024 -0500
@@ -295,8 +295,7 @@
{
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)
--- a/pidgin/pidginaccountfilterprotocol.c Fri May 10 01:10:09 2024 -0500
+++ b/pidgin/pidginaccountfilterprotocol.c Mon May 13 23:28:20 2024 -0500
@@ -44,10 +44,9 @@
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);
+ }
}
/******************************************************************************
--- a/pidgin/pidgindisplayitem.c Fri May 10 01:10:09 2024 -0500
+++ b/pidgin/pidgindisplayitem.c Mon May 13 23:28:20 2024 -0500
@@ -71,14 +71,9 @@
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 @@
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 @@
{
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
--- a/pidgin/pidgininfopane.c Fri May 10 01:10:09 2024 -0500
+++ b/pidgin/pidgininfopane.c Mon May 13 23:28:20 2024 -0500
@@ -197,10 +197,7 @@
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 @@
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]);
}
}
--- a/pidgin/pidginpresenceicon.c Fri May 10 01:10:09 2024 -0500
+++ b/pidgin/pidginpresenceicon.c Mon May 13 23:28:20 2024 -0500
@@ -256,16 +256,15 @@
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
--- a/pidgin/plugins/disco/xmppdiscoservice.c Fri May 10 01:10:09 2024 -0500
+++ b/pidgin/plugins/disco/xmppdiscoservice.c Mon May 13 23:28:20 2024 -0500
@@ -322,10 +322,9 @@
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 @@
{
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 @@
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 @@
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 @@
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
--- a/protocols/ircv3/purpleircv3message.c Fri May 10 01:10:09 2024 -0500
+++ b/protocols/ircv3/purpleircv3message.c Mon May 13 23:28:20 2024 -0500
@@ -210,10 +210,7 @@
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 @@
{
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]);
}
}