aboutsummaryrefslogtreecommitdiff
path: root/src/main/iconv.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/iconv.c')
-rw-r--r--src/main/iconv.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/main/iconv.c b/src/main/iconv.c
index 3f95d44..7daa017 100644
--- a/src/main/iconv.c
+++ b/src/main/iconv.c
@@ -33,10 +33,10 @@
33 * @param inSize number of bytes in 'in' 33 * @param inSize number of bytes in 'in'
34 * @return NULL on error, otherwise the converted string (to be free'd by caller) 34 * @return NULL on error, otherwise the converted string (to be free'd by caller)
35 */ 35 */
36static char * 36static char *
37iconv_helper (iconv_t cd, 37iconv_helper (iconv_t cd,
38 const char *in, 38 const char *in,
39 size_t inSize) 39 size_t inSize)
40{ 40{
41#if HAVE_ICONV 41#if HAVE_ICONV
42 char *buf; 42 char *buf;
@@ -57,24 +57,25 @@ iconv_helper (iconv_t cd,
57 ibuf = buf; 57 ibuf = buf;
58 memset (buf, 0, outSize); 58 memset (buf, 0, outSize);
59 if (iconv (cd, 59 if (iconv (cd,
60 (char**) &in, 60 (char**) &in,
61 &inSize, 61 &inSize,
62 &ibuf, 62 &ibuf,
63 &outLeft) == SIZE_MAX) 63 &outLeft) == SIZE_MAX)
64 { 64 {
65 /* conversion failed */ 65 /* conversion failed */
66 free (buf); 66 free (buf);
67 return strdup (i); 67 return strdup (i);
68 } 68 }
69 return buf; 69 return buf;
70#else 70#else
71 /* good luck, just copying string... */ 71 /* good luck, just copying string... */
72 char *buf; 72 char *buf;
73 73
74 buf = malloc (inSize + 1); 74 buf = malloc (inSize + 1);
75 memcpy (buf, in, inSize); 75 memcpy (buf, in, inSize);
76 buf[inSize] = '\0'; 76 buf[inSize] = '\0';
77#endif 77#endif
78} 78}
79 79
80
80/* end of iconv.c */ 81/* end of iconv.c */