]> sjero.net Git - wget/blobdiff - src/iri.c
Fix Test-iri-list.
[wget] / src / iri.c
index b1e0bf89cd9bc2a9caf55e2e533f1cc2b6a23d12..1803ca710698f19048be43dcfb1164bbbede182d 100644 (file)
--- a/src/iri.c
+++ b/src/iri.c
@@ -295,7 +295,7 @@ remote_to_utf8 (struct iri *i, const char *str, const char **new)
 struct iri *
 iri_new (void)
 {
-  struct iri *i = xmalloc (sizeof (struct iri));
+  struct iri *i = xmalloc (sizeof *i);
   i->uri_encoding = opt.encoding_remote ? xstrdup (opt.encoding_remote) : NULL;
   i->content_encoding = NULL;
   i->orig_url = NULL;
@@ -303,6 +303,17 @@ iri_new (void)
   return i;
 }
 
+struct iri *iri_dup (const struct iri *src)
+{
+  struct iri *i = xmalloc (sizeof *i);
+  i->uri_encoding = src->uri_encoding ? xstrdup (src->uri_encoding) : NULL;
+  i->content_encoding = (src->content_encoding ?
+                         xstrdup (src->content_encoding) : NULL);
+  i->orig_url = src->orig_url ? xstrdup (src->orig_url) : NULL;
+  i->utf8_encode = src->utf8_encode;
+  return i;
+}
+
 /* Completely free an iri structure. */
 void
 iri_free (struct iri *i)