summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2004-06-10 19:10:21 +0500
committerunknown <bar@mysql.com>2004-06-10 19:10:21 +0500
commitd8f0df52d307ba3d1aea9c3d9a125c9439e22e33 (patch)
tree6b4077bc259e31398c158a35a49ae7ceaac96b12 /mysys
parent7ece3c749152fd9a5df821398852a4cb02ec13a2 (diff)
downloadmariadb-git-d8f0df52d307ba3d1aea9c3d9a125c9439e22e33.tar.gz
Optimization to use less memory.
Diffstat (limited to 'mysys')
-rw-r--r--mysys/charset.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/mysys/charset.c b/mysys/charset.c
index a9c733e25cf..d2d71689d7b 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -406,12 +406,21 @@ static void set_max_sort_char(CHARSET_INFO *cs)
}
-static void init_state_maps(CHARSET_INFO *cs)
+static my_bool init_state_maps(CHARSET_INFO *cs)
{
uint i;
- uchar *state_map= cs->state_map;
- uchar *ident_map= cs->ident_map;
+ uchar *state_map;
+ uchar *ident_map;
+ if (!(cs->state_map= (uchar*) my_once_alloc(256, MYF(MY_WME))))
+ return 1;
+
+ if (!(cs->ident_map= (uchar*) my_once_alloc(256, MYF(MY_WME))))
+ return 1;
+
+ state_map= cs->state_map;
+ ident_map= cs->ident_map;
+
/* Fill state_map with states to get a faster parser */
for (i=0; i < 256 ; i++)
{
@@ -458,6 +467,7 @@ static void init_state_maps(CHARSET_INFO *cs)
state_map[(uchar)'x']= state_map[(uchar)'X']= (uchar) MY_LEX_IDENT_OR_HEX;
state_map[(uchar)'b']= state_map[(uchar)'b']= (uchar) MY_LEX_IDENT_OR_BIN;
state_map[(uchar)'n']= state_map[(uchar)'N']= (uchar) MY_LEX_IDENT_OR_NCHAR;
+ return 0;
}
@@ -582,7 +592,8 @@ static int simple_cs_copy_data(CHARSET_INFO *to, CHARSET_INFO *from)
MY_CS_CTYPE_TABLE_SIZE,
MYF(MY_WME))))
goto err;
- init_state_maps(to);
+ if (init_state_maps(to))
+ goto err;
}
if (from->to_lower)
if (!(to->to_lower= (uchar*) my_once_memdup((char*) from->to_lower,
@@ -601,6 +612,8 @@ static int simple_cs_copy_data(CHARSET_INFO *to, CHARSET_INFO *from)
MY_CS_SORT_ORDER_TABLE_SIZE,
MYF(MY_WME))))
goto err;
+
+
set_max_sort_char(to);
}
if (from->tab_to_uni)
@@ -1108,7 +1121,8 @@ static my_bool init_available_charsets(myf myflags)
{
set_max_sort_char(*cs);
if (cs[0]->ctype)
- init_state_maps(*cs);
+ if (init_state_maps(*cs))
+ *cs= NULL;
}
}