summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/lib/charset/charcnv.c7
-rw-r--r--source4/lib/charset/iconv.c20
-rw-r--r--source4/lib/charset/tests/iconv.c4
-rw-r--r--source4/param/loadparm.c2
-rw-r--r--source4/torture/smbiconv.c2
5 files changed, 22 insertions, 13 deletions
diff --git a/source4/lib/charset/charcnv.c b/source4/lib/charset/charcnv.c
index 9a4068a4a9..54a0676599 100644
--- a/source4/lib/charset/charcnv.c
+++ b/source4/lib/charset/charcnv.c
@@ -134,7 +134,8 @@ static smb_iconv_t get_conv_handle(struct smb_iconv_convenience *ic,
n1 = charset_name(ic, from);
n2 = charset_name(ic, to);
- ic->conv_handles[from][to] = smb_iconv_open(n2, n1, ic->native_iconv);
+ ic->conv_handles[from][to] = smb_iconv_open_ex(ic, n2, n1,
+ ic->native_iconv);
if (ic->conv_handles[from][to] == (smb_iconv_t)-1) {
if ((from == CH_DOS || to == CH_DOS) &&
@@ -146,8 +147,8 @@ static smb_iconv_t get_conv_handle(struct smb_iconv_convenience *ic,
n1 = charset_name(ic, from);
n2 = charset_name(ic, to);
- ic->conv_handles[from][to] = smb_iconv_open(n2, n1,
- ic->native_iconv);
+ ic->conv_handles[from][to] =
+ smb_iconv_open_ex(ic, n2, n1, ic->native_iconv);
}
}
diff --git a/source4/lib/charset/iconv.c b/source4/lib/charset/iconv.c
index 937b3ec8b5..db212a83c4 100644
--- a/source4/lib/charset/iconv.c
+++ b/source4/lib/charset/iconv.c
@@ -154,17 +154,17 @@ static bool is_utf16(const char *name)
strcasecmp(name, "UTF-16LE") == 0;
}
-/*
- simple iconv_open() wrapper
- */
-smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode,
- bool native_iconv)
+
+
+smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode,
+ const char *fromcode, bool native_iconv)
{
smb_iconv_t ret;
const struct charset_functions *from=NULL, *to=NULL;
int i;
- ret = (smb_iconv_t)talloc_named(NULL, sizeof(*ret),
+ ret = (smb_iconv_t)talloc_named(mem_ctx,
+ sizeof(*ret),
"iconv(%s,%s)", tocode, fromcode);
if (!ret) {
errno = ENOMEM;
@@ -261,6 +261,14 @@ failed:
}
/*
+ simple iconv_open() wrapper
+ */
+smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode)
+{
+ return smb_iconv_open_ex(NULL, tocode, fromcode, true);
+}
+
+/*
simple iconv_close() wrapper
*/
int smb_iconv_close(smb_iconv_t cd)
diff --git a/source4/lib/charset/tests/iconv.c b/source4/lib/charset/tests/iconv.c
index d47390b814..aeb42c2fa1 100644
--- a/source4/lib/charset/tests/iconv.c
+++ b/source4/lib/charset/tests/iconv.c
@@ -157,8 +157,8 @@ static bool test_buffer(struct torture_context *test,
"failed to open %s to UTF-16LE",
charset));
}
- cd2 = smb_iconv_open(charset, "UTF-16LE", lp_parm_bool(test->lp_ctx, NULL, "iconv", "native", true));
- cd3 = smb_iconv_open("UTF-16LE", charset, lp_parm_bool(test->lp_ctx, NULL, "iconv", "native", true));
+ cd2 = smb_iconv_open_ex(test, charset, "UTF-16LE", lp_parm_bool(test->lp_ctx, NULL, "iconv", "native", true));
+ cd3 = smb_iconv_open_ex(test, "UTF-16LE", charset, lp_parm_bool(test->lp_ctx, NULL, "iconv", "native", true));
last_charset = charset;
}
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index d732a09f2f..6c23a1d520 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -2466,7 +2466,7 @@ bool lp_load(struct loadparm_context *lp_ctx, const char *filename)
/* FIXME: Check locale in environment for this: */
if (strcmp(lp_display_charset(lp_ctx), lp_unix_charset(lp_ctx)) != 0)
- d_set_iconv(smb_iconv_open(lp_display_charset(lp_ctx), lp_unix_charset(lp_ctx), true));
+ d_set_iconv(smb_iconv_open(lp_display_charset(lp_ctx), lp_unix_charset(lp_ctx)));
else
d_set_iconv((smb_iconv_t)-1);
diff --git a/source4/torture/smbiconv.c b/source4/torture/smbiconv.c
index 1eb09cae45..4eece66bdf 100644
--- a/source4/torture/smbiconv.c
+++ b/source4/torture/smbiconv.c
@@ -205,7 +205,7 @@ int main(int argc, char *argv[])
}
}
- cd = smb_iconv_open(to, from, lp_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
+ cd = smb_iconv_open_ex(tctx, to, from, lp_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
if((int)cd == -1) {
DEBUG(0,("unable to find from or to encoding, exiting...\n"));
return 1;