~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/thr_malloc.cc

Finished first pass at Protocol cleanup, still some things to remove but they are a bit more involved.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
/* Mallocs for used in threads */
18
18
 
19
19
#include <drizzled/server_includes.h>
20
 
#include <drizzled/drizzled_error_messages.h>
 
20
#include <drizzled/current_session.h>
 
21
#include <drizzled/error.h>
21
22
 
22
23
extern "C" {
23
24
  void sql_alloc_error_handler(void)
24
25
  {
25
 
    sql_print_error(ER(ER_OUT_OF_RESOURCES));
 
26
    errmsg_printf(ERRMSG_LVL_ERROR, "%s",ER(ER_OUT_OF_RESOURCES));
26
27
  }
27
28
}
28
29
 
29
 
void init_sql_alloc(MEM_ROOT *mem_root, uint32_t block_size, uint32_t pre_alloc)
 
30
void init_sql_alloc(MEM_ROOT *mem_root, size_t block_size, size_t pre_alloc)
30
31
{
31
32
  init_alloc_root(mem_root, block_size, pre_alloc);
32
33
  mem_root->error_handler=sql_alloc_error_handler;
35
36
 
36
37
void *sql_alloc(size_t Size)
37
38
{
38
 
  MEM_ROOT *root= *(MEM_ROOT **)pthread_getspecific(THR_MALLOC);
 
39
  MEM_ROOT *root= current_mem_root();
39
40
  return alloc_root(root,Size);
40
41
}
41
42
 
79
80
  return pos;
80
81
}
81
82
 
82
 
void sql_element_free(void *ptr __attribute__((unused)))
 
83
void sql_element_free(void *)
83
84
{} /* purecov: deadcode */
84
85
 
85
86
 
86
87
 
87
88
char *sql_strmake_with_convert(const char *str, size_t arg_length,
88
 
                               const CHARSET_INFO * const from_cs,
89
 
                               size_t max_res_length,
90
 
                               const CHARSET_INFO * const to_cs, size_t *result_length)
 
89
                               const CHARSET_INFO * const from_cs,
 
90
                               size_t max_res_length,
 
91
                               const CHARSET_INFO * const to_cs,
 
92
                               size_t *result_length)
91
93
{
92
94
  char *pos;
93
95
  size_t new_length= to_cs->mbmaxlen*arg_length;