summaryrefslogtreecommitdiff
path: root/source3/lib/charcnv.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/charcnv.c')
-rw-r--r--source3/lib/charcnv.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index f025e93718..00670f4a85 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -59,7 +59,7 @@ static const char *charset_name(charset_t ch)
return ret;
}
-static void lazy_initialize_conv(void)
+void lazy_initialize_conv(void)
{
static int initialized = False;
@@ -67,14 +67,16 @@ static void lazy_initialize_conv(void)
initialized = True;
load_case_tables();
init_iconv();
- init_valid_table();
}
}
/**
- Initialize iconv conversion descriptors.
-**/
-
+ * Initialize iconv conversion descriptors.
+ *
+ * This is called the first time it is needed, and also called again
+ * every time the configuration is reloaded, because the charset or
+ * codepage might have changed.
+ **/
void init_iconv(void)
{
int c1, c2;
@@ -112,6 +114,10 @@ void init_iconv(void)
}
if (did_reload) {
+ /* XXX: Does this really get called every time the dos
+ * codepage changes? */
+ /* XXX: Is the did_reload test too strict? */
+ init_doschar_table();
init_valid_table();
}
}
@@ -214,14 +220,14 @@ size_t convert_string_allocate(charset_t from, charset_t to,
outbuf = NULL;
convert:
destlen = destlen * 2;
- ob = (char *)Realloc(outbuf, destlen);
+ ob = (char *)realloc(outbuf, destlen);
if (!ob) {
DEBUG(0, ("convert_string_allocate: realloc failed!\n"));
SAFE_FREE(outbuf);
return (size_t)-1;
- } else {
- outbuf = ob;
}
+ else
+ outbuf = ob;
i_len = srclen;
o_len = destlen;
retval = smb_iconv(descriptor,
@@ -639,11 +645,11 @@ size_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src)
* @returns The number of bytes occupied by the string in the destination
**/
-size_t pull_ucs2_allocate(char **dest, const smb_ucs2_t *src)
+size_t pull_ucs2_allocate(void **dest, const smb_ucs2_t *src)
{
size_t src_len = (strlen_w(src)+1) * sizeof(smb_ucs2_t);
*dest = NULL;
- return convert_string_allocate(CH_UCS2, CH_UNIX, src, src_len, (void **)dest);
+ return convert_string_allocate(CH_UCS2, CH_UNIX, src, src_len, dest);
}
/**