summaryrefslogtreecommitdiff
path: root/source3/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
commitc4fe824c42a36f19d19eb5cca5f62f883410ab98 (patch)
tree2af27483d957c0f05c17e3559f9f843c5a249420 /source3/lib
parenta4bd608b48d58aca0d0d2833fd9dd0c2d35480c9 (diff)
downloadsamba-c4fe824c42a36f19d19eb5cca5f62f883410ab98.tar.gz
samba-c4fe824c42a36f19d19eb5cca5f62f883410ab98.tar.bz2
samba-c4fe824c42a36f19d19eb5cca5f62f883410ab98.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(). (This used to be commit 7f7d22880d40c7344bc402203dd150255fc694cf)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/charcnv.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index 481effbad5..48b9cad731 100644
--- a/source3/lib/charcnv.c
+++ b/source3/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];