about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorSteffen Jaeckel <jaeckel-floss@eyet-services.de>2023-03-10 11:16:51 +0100
committerSteffen Jaeckel <jaeckel-floss@eyet-services.de>2023-03-11 15:05:03 +0100
commite99c4b7128f5c95cf8665ef969848defa0d3bbd7 (patch)
tree6b9242d101055b9dbba0eb9fca853201d49931ab /src/xmpp
parent92eed34fb3ae8148ab71ae7581c3f01e46606d28 (diff)
downloadprofani-tty-e99c4b7128f5c95cf8665ef969848defa0d3bbd7.tar.gz
simplify some code
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/connection.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index be0c8418..3eca29c4 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -863,12 +863,8 @@ _split_url(const char* alturi, gchar** host, gint* port)
     /* Construct a valid URI with `schema://` as `g_uri_split_network()`
      * requires this to be there.
      */
-    const char* xmpp = "xmpp://";
-    char* xmpp_uri = _xmalloc(strlen(xmpp) + strlen(alturi) + 1, NULL);
-    memcpy(xmpp_uri, xmpp, strlen(xmpp));
-    memcpy(xmpp_uri + strlen(xmpp), alturi, strlen(alturi) + 1);
+    auto_gchar gchar* xmpp_uri = g_strdup_printf("xmpp://%s", alturi);
     gboolean ret = g_uri_split_network(xmpp_uri, 0, NULL, host, port, NULL);
-    free(xmpp_uri);
     /* fix-up `port` as g_uri_split_network() sets port to `-1` if it's missing
      * in the passed-in URI, but libstrophe expects a "missing port"
      * to be passed as `0` (which then results in connecting to the standard port).