~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/thr_malloc.cc

  • Committer: Monty Taylor
  • Date: 2008-10-16 06:32:30 UTC
  • mto: (511.1.5 codestyle)
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: monty@inaugust.com-20081016063230-4brxsra0qsmsg84q
Added -Wunused-macros.

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