From e99c4b7128f5c95cf8665ef969848defa0d3bbd7 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Fri, 10 Mar 2023 11:16:51 +0100 Subject: simplify some code Signed-off-by: Steffen Jaeckel --- src/xmpp/connection.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/xmpp') 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). -- cgit 1.4.1-2-gfad0