diff options
author | monty@mashka.mysql.fi <> | 2003-05-21 21:39:58 +0300 |
---|---|---|
committer | monty@mashka.mysql.fi <> | 2003-05-21 21:39:58 +0300 |
commit | 6aa8929cf37374fe74c31eb03007961fa119213a (patch) | |
tree | 3df25ac7036fb4b2e95ab56b9dc90477ec234b7c /sql/thr_malloc.cc | |
parent | dd2b7918cdd5e0e643cff0305542ccd4aa8f1b6b (diff) | |
download | mariadb-git-6aa8929cf37374fe74c31eb03007961fa119213a.tar.gz |
After merge fixes
Added initialization of all important global variables
Diffstat (limited to 'sql/thr_malloc.cc')
-rw-r--r-- | sql/thr_malloc.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sql/thr_malloc.cc b/sql/thr_malloc.cc index 57560715fbe..fa678ec7de2 100644 --- a/sql/thr_malloc.cc +++ b/sql/thr_malloc.cc @@ -85,3 +85,33 @@ gptr sql_memdup(const void *ptr,uint len) void sql_element_free(void *ptr __attribute__((unused))) {} /* purecov: deadcode */ + + + +char *sql_strmake_with_convert(const char *str, uint32 arg_length, + CHARSET_INFO *from_cs, + uint32 max_res_length, + CHARSET_INFO *to_cs, uint32 *result_length) +{ + char *pos; + uint32 new_length= to_cs->mbmaxlen*arg_length; + max_res_length--; // Reserve place for end null + + set_if_smaller(new_length, max_res_length); + if (!(pos= sql_alloc(new_length+1))) + return pos; // Error + + if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin)) + { + // Safety if to_cs->mbmaxlen > 0 + new_length= min(arg_length, max_res_length); + memcpy(pos, str, new_length); + } + else + new_length= copy_and_convert((char*) pos, new_length, to_cs, str, + arg_length, from_cs); + pos[new_length]= 0; + *result_length= new_length; + return pos; +} + |