~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/thr_malloc.cc

  • Committer: Monty Taylor
  • Date: 2009-06-08 18:19:53 UTC
  • mto: This revision was merged to the branch mainline in revision 1060.
  • Revision ID: mordred@inaugust.com-20090608181953-9n1u3im0kezu2aoy
Removed copy_and_convert.

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
  return pos;
81
81
}
82
82
 
83
 
char *sql_strmake_with_convert(const char *str, size_t arg_length,
84
 
                               const CHARSET_INFO * const from_cs,
85
 
                               size_t max_res_length,
86
 
                               const CHARSET_INFO * const to_cs,
87
 
                               size_t *result_length)
88
 
{
89
 
  char *pos;
90
 
  size_t new_length= to_cs->mbmaxlen*arg_length;
91
 
  max_res_length--;                             // Reserve place for end null
92
 
 
93
 
  set_if_smaller(new_length, max_res_length);
94
 
  if (!(pos= (char*) sql_alloc(new_length+1)))
95
 
    return pos;                                 // Error
96
 
 
97
 
  if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
98
 
  {
99
 
    // Safety if to_cs->mbmaxlen > 0
100
 
    new_length= cmin(arg_length, max_res_length);
101
 
    memcpy(pos, str, new_length);
102
 
  }
103
 
  else
104
 
  {
105
 
    uint32_t dummy_errors;
106
 
    new_length= copy_and_convert((char*) pos, new_length, to_cs, str,
107
 
                                 arg_length, from_cs, &dummy_errors);
108
 
  }
109
 
  pos[new_length]= 0;
110
 
  *result_length= new_length;
111
 
  return pos;
112
 
}
113