Commit 1efa7ea5 authored by unknown's avatar unknown

Critical fixes after review:

- mutex was unlocked before the end of the critical sesion,
- Portability issue: It's better to use (*alloc)(x) instead of alloc(x),
  if alloc is a function passed as an argument.
- Use {} around if() block, to avoid possible problems with some Windows compilers.

parent 7f7c311b
...@@ -469,7 +469,6 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags) ...@@ -469,7 +469,6 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags)
} }
cs= (cs->state & MY_CS_AVAILABLE) ? cs : NULL; cs= (cs->state & MY_CS_AVAILABLE) ? cs : NULL;
} }
pthread_mutex_unlock(&THR_LOCK_charset);
if (cs && !(cs->state & MY_CS_READY)) if (cs && !(cs->state & MY_CS_READY))
{ {
if ((cs->cset->init && cs->cset->init(cs, cs_alloc)) || if ((cs->cset->init && cs->cset->init(cs, cs_alloc)) ||
...@@ -478,6 +477,7 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags) ...@@ -478,6 +477,7 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags)
else else
cs->state|= MY_CS_READY; cs->state|= MY_CS_READY;
} }
pthread_mutex_unlock(&THR_LOCK_charset);
return cs; return cs;
} }
......
...@@ -370,7 +370,7 @@ bool String::copy(const char *str, uint32 arg_length, ...@@ -370,7 +370,7 @@ bool String::copy(const char *str, uint32 arg_length,
bool String::set_ascii(const char *str, uint32 arg_length) bool String::set_ascii(const char *str, uint32 arg_length)
{ {
if (!(str_charset->mbminlen > 1)) if (str_charset->mbminlen == 1)
{ {
set(str, arg_length, str_charset); set(str, arg_length, str_charset);
return 0; return 0;
......
...@@ -7549,8 +7549,8 @@ typedef struct my_coll_rule_item_st ...@@ -7549,8 +7549,8 @@ typedef struct my_coll_rule_item_st
USAGE USAGE
RETURN VALUES RETURN VALUES
0 - OK A positive number means the number of rules loaded.
1 - ERROR, e.g. too many items. -1 means ERROR, e.g. too many items, syntax error, etc.
*/ */
static int my_coll_rule_parse(MY_COLL_RULE *rule, size_t mitems, static int my_coll_rule_parse(MY_COLL_RULE *rule, size_t mitems,
...@@ -7706,11 +7706,11 @@ static my_bool create_tailoring(CHARSET_INFO *cs, void *(*alloc)(uint)) ...@@ -7706,11 +7706,11 @@ static my_bool create_tailoring(CHARSET_INFO *cs, void *(*alloc)(uint))
return 1; return 1;
} }
if (!(newweights= (uint16**) alloc(256*sizeof(uint16*)))) if (!(newweights= (uint16**) (*alloc)(256*sizeof(uint16*))))
return 1; return 1;
bzero(newweights, 256*sizeof(uint16*)); bzero(newweights, 256*sizeof(uint16*));
if (!(newlengths= (uchar*) alloc(256))) if (!(newlengths= (uchar*) (*alloc)(256)))
return 1; return 1;
memcpy(newlengths, deflengths, 256); memcpy(newlengths, deflengths, 256);
...@@ -7747,7 +7747,7 @@ static my_bool create_tailoring(CHARSET_INFO *cs, void *(*alloc)(uint)) ...@@ -7747,7 +7747,7 @@ static my_bool create_tailoring(CHARSET_INFO *cs, void *(*alloc)(uint))
/* Alloc new page and copy the default UCA weights */ /* Alloc new page and copy the default UCA weights */
uint size= 256*newlengths[pagec]*sizeof(uint16); uint size= 256*newlengths[pagec]*sizeof(uint16);
if (!(newweights[pagec]= (uint16*) alloc(size))) if (!(newweights[pagec]= (uint16*) (*alloc)(size)))
return 1; return 1;
bzero((void*) newweights[pagec], size); bzero((void*) newweights[pagec], size);
...@@ -7774,8 +7774,10 @@ static my_bool create_tailoring(CHARSET_INFO *cs, void *(*alloc)(uint)) ...@@ -7774,8 +7774,10 @@ static my_bool create_tailoring(CHARSET_INFO *cs, void *(*alloc)(uint))
/* Copy non-overwritten pages from the default UCA weights */ /* Copy non-overwritten pages from the default UCA weights */
for (i= 0; i < 256 ; i++) for (i= 0; i < 256 ; i++)
{
if (!newweights[i]) if (!newweights[i])
newweights[i]= defweights[i]; newweights[i]= defweights[i];
}
cs->sort_order= newlengths; cs->sort_order= newlengths;
cs->sort_order_big= newweights; cs->sort_order_big= newweights;
...@@ -7785,7 +7787,7 @@ static my_bool create_tailoring(CHARSET_INFO *cs, void *(*alloc)(uint)) ...@@ -7785,7 +7787,7 @@ static my_bool create_tailoring(CHARSET_INFO *cs, void *(*alloc)(uint))
if (ncontractions) if (ncontractions)
{ {
uint size= 0x40*0x40*sizeof(uint16); /* 8K, for basic latin letter only */ uint size= 0x40*0x40*sizeof(uint16); /* 8K, for basic latin letter only */
if (!(cs->contractions= (uint16*) alloc(size))) if (!(cs->contractions= (uint16*) (*alloc)(size)))
return 1; return 1;
bzero((void*)cs->contractions, size); bzero((void*)cs->contractions, size);
for (i=0; i < rc; i++) for (i=0; i < rc; i++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment