~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/thr_malloc.cc

  • Committer: Monty Taylor
  • Date: 2008-07-05 18:10:38 UTC
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: monty@inaugust.com-20080705181038-0ih0nnamu5qrut0y
Fixed prototypes. Cleaned define a little bit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
/* Mallocs for used in threads */
18
18
 
19
 
#include <drizzled/server_includes.h>
20
 
#include <drizzled/drizzled_error_messages.h>
 
19
#include "mysql_priv.h"
21
20
 
22
21
extern "C" {
23
22
  void sql_alloc_error_handler(void)
26
25
  }
27
26
}
28
27
 
29
 
void init_sql_alloc(MEM_ROOT *mem_root, uint32_t block_size, uint32_t pre_alloc)
 
28
void init_sql_alloc(MEM_ROOT *mem_root, uint block_size, uint pre_alloc)
30
29
{
31
30
  init_alloc_root(mem_root, block_size, pre_alloc);
32
31
  mem_root->error_handler=sql_alloc_error_handler;
44
43
{
45
44
  void *ptr;
46
45
  if ((ptr=sql_alloc(size)))
47
 
    memset(ptr, 0, size);
 
46
    bzero(ptr,size);
48
47
  return ptr;
49
48
}
50
49
 
85
84
 
86
85
 
87
86
char *sql_strmake_with_convert(const char *str, size_t arg_length,
88
 
                               const CHARSET_INFO * const from_cs,
 
87
                               CHARSET_INFO *from_cs,
89
88
                               size_t max_res_length,
90
 
                               const CHARSET_INFO * const to_cs, size_t *result_length)
 
89
                               CHARSET_INFO *to_cs, size_t *result_length)
91
90
{
92
91
  char *pos;
93
92
  size_t new_length= to_cs->mbmaxlen*arg_length;
100
99
  if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
101
100
  {
102
101
    // Safety if to_cs->mbmaxlen > 0
103
 
    new_length= cmin(arg_length, max_res_length);
 
102
    new_length= min(arg_length, max_res_length);
104
103
    memcpy(pos, str, new_length);
105
104
  }
106
105
  else
107
106
  {
108
 
    uint32_t dummy_errors;
 
107
    uint dummy_errors;
109
108
    new_length= copy_and_convert((char*) pos, new_length, to_cs, str,
110
109
                                 arg_length, from_cs, &dummy_errors);
111
110
  }