> From: Giuseppe Scrivano <[email protected]>
> Cc: [email protected], [email protected]
> Date: Wed, 16 Dec 2015 10:53:51 +0100
>
> > + for (;;)
> > + {
> > + if (iconv (cd, &fname, &inlen, &s, &outlen) != (size_t)(-1))
> > + {
> > + /* Flush the last bytes. */
> > + iconv (cd, NULL, NULL, &s, &outlen);
>
> should not the return code be checked here?
We should probably simply copy what iri.c does in a similar function,
yes.
> > + else if (errno == E2BIG) /* Output buffer full */
> > + {
> > + char *new;
> > +
> > + done = len;
> > + outlen = done + inlen * 2;
> > + new = xmalloc (outlen + 1);
> > + memcpy (new, converted_fname, done);
> > + xfree (converted_fname);
>
> What would be the extra cost in terms of copied bytes if we just replace
> the three lines above with xrealloc?
I don't know, probably nothing. This is simply copied (with trivial
changes) from do_conversion in iri.c, so if we want to make that
change, we should do it there as well.
Thanks.