xeme/xeme

Use g_set_str everywhere
default tip
2 weeks ago, Elliott Sales de Andrade
5d0707ab10a2
Parents 0822a5847e59
Children
Use g_set_str everywhere

This simplifies some setters.

Testing Done:
Ran `ninja turtles`

Reviewed at https://reviews.imfreedom.org/r/3181/
--- a/xeme/xemeconnection.c Wed Mar 20 23:28:27 2024 -0500
+++ b/xeme/xemeconnection.c Mon May 13 23:31:43 2024 -0500
@@ -439,10 +439,7 @@
{
g_return_if_fail(XEME_IS_CONNECTION(connection));
- if(!xeme_str_equal(connection->resource, resource)) {
- g_free(connection->resource);
- connection->resource = g_strdup(resource);
-
+ if(g_set_str(&connection->resource, resource)) {
g_object_notify_by_pspec(G_OBJECT(connection),
properties[PROP_RESOURCE]);
}
@@ -459,10 +456,7 @@
xeme_connection_set_server(XemeConnection *connection, const char *server) {
g_return_if_fail(XEME_IS_CONNECTION(connection));
- if(!xeme_str_equal(connection->server, server)) {
- g_free(connection->server);
- connection->server = g_strdup(server);
-
+ if(g_set_str(&connection->server, server)) {
g_object_notify_by_pspec(G_OBJECT(connection),
properties[PROP_SERVER]);
}
--- a/xeme/xemeextension.c Wed Mar 20 23:28:27 2024 -0500
+++ b/xeme/xemeextension.c Mon May 13 23:31:43 2024 -0500
@@ -45,10 +45,7 @@
priv = xeme_extension_get_instance_private(extension);
- if(!xeme_str_equal(priv->element, element)) {
- g_free(priv->element);
- priv->element = g_strdup(element);
-
+ if(g_set_str(&priv->element, element)) {
g_object_notify_by_pspec(G_OBJECT(extension),
properties[PROP_ELEMENT]);
}
@@ -62,10 +59,7 @@
priv = xeme_extension_get_instance_private(extension);
- if(!xeme_str_equal(priv->namespace, namespace)) {
- g_free(priv->namespace);
- priv->namespace = g_strdup(namespace);
-
+ if(g_set_str(&priv->namespace, namespace)) {
g_object_notify_by_pspec(G_OBJECT(extension),
properties[PROP_NAMESPACE]);
}
--- a/xeme/xememessage.c Wed Mar 20 23:28:27 2024 -0500
+++ b/xeme/xememessage.c Mon May 13 23:31:43 2024 -0500
@@ -282,10 +282,7 @@
xeme_message_set_thread(XemeMessage *message, const char *thread) {
g_return_if_fail(XEME_IS_MESSAGE(message));
- if(g_strcmp0(message->thread, thread) != 0) {
- g_free(message->thread);
- message->thread = g_strdup(thread);
-
+ if(g_set_str(&message->thread, thread)) {
g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_THREAD]);
}
}
@@ -303,10 +300,7 @@
{
g_return_if_fail(XEME_IS_MESSAGE(message));
- if(g_strcmp0(message->thread_parent, thread_parent) != 0) {
- g_free(message->thread_parent);
- message->thread_parent = g_strdup(thread_parent);
-
+ if(g_set_str(&message->thread_parent, thread_parent)) {
g_object_notify_by_pspec(G_OBJECT(message),
properties[PROP_THREAD_PARENT]);
}
--- a/xeme/xemestanza.c Wed Mar 20 23:28:27 2024 -0500
+++ b/xeme/xemestanza.c Mon May 13 23:31:43 2024 -0500
@@ -215,10 +215,7 @@
priv = xeme_stanza_get_instance_private(stanza);
- if(g_strcmp0(priv->content_type, content_type) != 0) {
- g_free(priv->content_type);
- priv->content_type = g_strdup(content_type);
-
+ if(g_set_str(&priv->content_type, content_type)) {
g_object_notify_by_pspec(G_OBJECT(stanza),
properties[PROP_CONTENT_TYPE]);
}
@@ -244,10 +241,7 @@
priv = xeme_stanza_get_instance_private(stanza);
- if(g_strcmp0(priv->from, from) != 0) {
- g_free(priv->from);
- priv->from = g_strdup(from);
-
+ if(g_set_str(&priv->from, from)) {
g_object_notify_by_pspec(G_OBJECT(stanza), properties[PROP_FROM]);
}
}
@@ -272,10 +266,7 @@
priv = xeme_stanza_get_instance_private(stanza);
- if(g_strcmp0(priv->id, id) != 0) {
- g_free(priv->id);
- priv->id = g_strdup(id);
-
+ if(g_set_str(&priv->id, id)) {
g_object_notify_by_pspec(G_OBJECT(stanza), properties[PROP_ID]);
}
}
@@ -300,10 +291,7 @@
priv = xeme_stanza_get_instance_private(stanza);
- if(g_strcmp0(priv->to, to) != 0) {
- g_free(priv->to);
- priv->to = g_strdup(to);
-
+ if(g_set_str(&priv->to, to)) {
g_object_notify_by_pspec(G_OBJECT(stanza),
properties[PROP_TO]);
}
@@ -328,10 +316,7 @@
priv = xeme_stanza_get_instance_private(stanza);
- if(g_strcmp0(priv->xml_lang, xml_lang) != 0) {
- g_free(priv->xml_lang);
- priv->xml_lang = g_strdup(xml_lang);
-
+ if(g_set_str(&priv->xml_lang, xml_lang)) {
g_object_notify_by_pspec(G_OBJECT(stanza), properties[PROP_XML_LANG]);
}
}
--- a/xeme/xemestream.c Wed Mar 20 23:28:27 2024 -0500
+++ b/xeme/xemestream.c Mon May 13 23:31:43 2024 -0500
@@ -270,10 +270,7 @@
priv = xeme_stream_get_instance_private(stream);
- if(g_strcmp0(priv->id, id) != 0) {
- g_free(priv->id);
- priv->id = g_strdup(id);
-
+ if(g_set_str(&priv->id, id)) {
g_object_notify_by_pspec(G_OBJECT(stream), properties[PROP_ID]);
}
}
@@ -297,10 +294,7 @@
priv = xeme_stream_get_instance_private(stream);
- if(g_strcmp0(priv->to, to) != 0) {
- g_free(priv->to);
- priv->to = g_strdup(to);
-
+ if(g_set_str(&priv->to, to)) {
g_object_notify_by_pspec(G_OBJECT(stream), properties[PROP_TO]);
}
}
@@ -324,10 +318,7 @@
priv = xeme_stream_get_instance_private(stream);
- if(g_strcmp0(priv->from, from) != 0) {
- g_free(priv->from);
- priv->from = g_strdup(from);
-
+ if(g_set_str(&priv->from, from)) {
g_object_notify_by_pspec(G_OBJECT(stream), properties[PROP_FROM]);
}
}
@@ -351,10 +342,7 @@
priv = xeme_stream_get_instance_private(stream);
- if(g_strcmp0(priv->language, language) != 0) {
- g_free(priv->language);
- priv->language = g_strdup(language);
-
+ if(g_set_str(&priv->language, language)) {
g_object_notify_by_pspec(G_OBJECT(stream),
properties[PROP_LANGUAGE]);
}
@@ -378,10 +366,7 @@
g_return_if_fail(XEME_IS_STREAM(stream));
priv = xeme_stream_get_instance_private(stream);
- if(!xeme_str_equal(priv->version, version)) {
- g_free(priv->version);
- priv->version = g_strdup(version);
-
+ if(g_set_str(&priv->version, version)) {
g_object_notify_by_pspec(G_OBJECT(stream), properties[PROP_VERSION]);
}
}