summaryrefslogtreecommitdiffstats
path: root/source/lib
diff options
context:
space:
mode:
authorMartin Pool <mbp@samba.org>2002-01-22 03:51:28 +0000
committerMartin Pool <mbp@samba.org>2002-01-22 03:51:28 +0000
commit7f7d22880d40c7344bc402203dd150255fc694cf (patch)
treea71b726b835a5c750e40bcc657b4d0f3fb460800 /source/lib
parent5fb3be62910faf91e0e8381ba91f314f2092cb8e (diff)
downloadsamba-7f7d22880d40c7344bc402203dd150255fc694cf.tar.gz
samba-7f7d22880d40c7344bc402203dd150255fc694cf.tar.xz
samba-7f7d22880d40c7344bc402203dd150255fc694cf.zip
We have to do some initialization before the string conversion
routines can work. The code was copied into both convert_string and convert_string_allocate -- I split it into a little static function, and removed an apparently duplicate call to init_valid_table().
Diffstat (limited to 'source/lib')
-rw-r--r--source/lib/charcnv.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/source/lib/charcnv.c b/source/lib/charcnv.c
index 481effbad52..48b9cad7319 100644
--- a/source/lib/charcnv.c
+++ b/source/lib/charcnv.c
@@ -27,8 +27,6 @@ static pstring cvtbuf;
static smb_iconv_t conv_handles[NUM_CHARSETS][NUM_CHARSETS];
-static int initialized;
-
/****************************************************************************
return the name of a charset to give to iconv()
****************************************************************************/
@@ -45,6 +43,19 @@ static char *charset_name(charset_t ch)
return ret;
}
+
+static void lazy_initialize_conv(void)
+{
+ static int initialized = False;
+
+ if (!initialized) {
+ initialized = True;
+ load_case_tables();
+ init_iconv();
+ init_valid_table();
+ }
+}
+
/****************************************************************************
Initialize iconv conversion descriptors
****************************************************************************/
@@ -112,12 +123,7 @@ size_t convert_string(charset_t from, charset_t to,
if (srclen == -1) srclen = strlen(src)+1;
- if (!initialized) {
- initialized = 1;
- load_case_tables();
- init_iconv();
- init_valid_table();
- }
+ lazy_initialize_conv();
descriptor = conv_handles[from][to];
@@ -174,11 +180,7 @@ size_t convert_string_allocate(charset_t from, charset_t to,
if (src == NULL || srclen == -1) return -1;
- if (!initialized) {
- initialized = 1;
- load_case_tables();
- init_iconv();
- }
+ lazy_initialize_conv();
descriptor = conv_handles[from][to];