diff --git a/src/connect.c b/src/connect.c index 7e181716..d665d6d9 100644 --- a/src/connect.c +++ b/src/connect.c @@ -56,10 +56,6 @@ as that of the covered work. */ #include <string.h> #include <sys/time.h> -#ifdef ENABLE_IRI -#include <idn2.h> -#endif - #include "utils.h" #include "host.h" #include "connect.h" @@ -280,11 +276,8 @@ connect_to_ip (const ip_address *ip, int port, const char *print) if (opt.enable_iri && (name = idn_decode ((char *) print)) != NULL) { - int len = strlen (print) + strlen (name) + 4; - str = xmalloc (len); - snprintf (str, len, "%s (%s)", name, print); - str[len-1] = '\0'; - idn2_free (name); + str = aprintf ("%s (%s)", name, print); + xfree (name); } logprintf (LOG_VERBOSE, _("Connecting to %s|%s|:%d... "), diff --git a/src/host.c b/src/host.c index 9f551c72..ccc6349d 100644 --- a/src/host.c +++ b/src/host.c @@ -57,10 +57,6 @@ as that of the covered work. */ #include <errno.h> -#ifdef ENABLE_IRI -#include <idn2.h> -#endif - #include "utils.h" #include "host.h" #include "url.h" @@ -846,11 +842,8 @@ lookup_host (const char *host, int flags) if (opt.enable_iri && (name = idn_decode ((char *) host)) != NULL) { - int len = strlen (host) + strlen (name) + 4; - str = xmalloc (len); - snprintf (str, len, "%s (%s)", name, host); - str[len-1] = '\0'; - idn2_free (name); + str = aprintf ("%s (%s)", name, host); + xfree (name); } logprintf (LOG_VERBOSE, _("Resolving %s... "), diff --git a/src/iri.h b/src/iri.h index ba64a275..fb994ee1 100644 --- a/src/iri.h +++ b/src/iri.h @@ -40,8 +40,6 @@ struct iri { #ifdef ENABLE_IRI -# include <idn2.h> - char *parse_charset (const char *str); const char *find_locale (void); bool check_encoding_name (const char *encoding); diff --git a/src/url.c b/src/url.c index 07b32a10..7f2376ff 100644 --- a/src/url.c +++ b/src/url.c @@ -944,7 +944,6 @@ url_parse (const char *url, int *error, struct iri *iri, bool percent_encode) { xfree (u->host); u->host = new; - u->idn_allocated = true; host_modified = true; } } @@ -1223,12 +1222,7 @@ url_free (struct url *url) { if (url) { - if (url->idn_allocated) { - idn2_free (url->host); /* A dummy if !defined(ENABLE_IRI) */ - url->host = NULL; - } - else - xfree (url->host); + xfree (url->host); xfree (url->path); xfree (url->url); diff --git a/src/url.h b/src/url.h index 94d1528c..ad58739b 100644 --- a/src/url.h +++ b/src/url.h @@ -99,10 +99,6 @@ struct url /* Username and password (unquoted). */ char *user; char *passwd; - - /* 'host' is allocated by idn2_lookup_u8() via idn_encode(). - * Call 'idn2_free()' to free this memory. */ - bool idn_allocated; }; /* Function declarations */