17
17
/* Mallocs for used in threads */
21
21
#include <string.h>
23
#include "drizzled/errmsg_print.h"
24
#include "drizzled/memory/sql_alloc.h"
25
#include "drizzled/current_session.h"
26
#include "drizzled/error.h"
27
#include "drizzled/definitions.h"
29
#include "drizzled/internal/my_sys.h"
34
static void sql_alloc_error_handler(void)
36
errmsg_printf(error::ERROR, "%s",ER(ER_OUT_OF_RESOURCES));
39
void memory::init_sql_alloc(memory::Root *mem_root, size_t block_size, size_t)
41
mem_root->init_alloc_root(block_size);
42
mem_root->error_handler= sql_alloc_error_handler;
46
void *memory::sql_alloc(size_t Size)
48
memory::Root *root= current_mem_root();
49
return root->alloc_root(Size);
53
void *memory::sql_calloc(size_t size)
57
if ((ptr=memory::sql_alloc(size)))
23
#include <drizzled/errmsg_print.h>
24
#include <drizzled/memory/sql_alloc.h>
25
#include <drizzled/current_session.h>
26
#include <drizzled/error.h>
27
#include <drizzled/definitions.h>
28
#include <drizzled/internal/my_sys.h>
33
void* sql_alloc(size_t Size)
35
return current_mem_root()->alloc(Size);
38
void* sql_calloc(size_t size)
40
void* ptr= sql_alloc(size);
64
char *memory::sql_strdup(const char *str)
66
size_t len= strlen(str)+1;
68
if ((pos= (char*) memory::sql_alloc(len)))
74
char *memory::sql_strmake(const char *str, size_t len)
77
if ((pos= (char*) memory::sql_alloc(len+1)))
86
void* memory::sql_memdup(const void *ptr, size_t len)
89
if ((pos= memory::sql_alloc(len)))
94
void *memory::SqlAlloc::operator new(size_t size)
96
return memory::sql_alloc(size);
99
void *memory::SqlAlloc::operator new[](size_t size)
101
return memory::sql_alloc(size);
104
void *memory::SqlAlloc::operator new[](size_t size, memory::Root *mem_root)
106
return mem_root->alloc_root(size);
109
void *memory::SqlAlloc::operator new(size_t size, memory::Root *mem_root)
111
return mem_root->alloc_root(size);
45
char* sql_strdup(const char* str)
47
size_t len= strlen(str) + 1;
48
char* pos= (char*) sql_alloc(len);
49
memcpy(pos, str, len);
53
char* sql_strmake(const char* str, size_t len)
55
char* pos= (char*) sql_alloc(len + 1);
56
memcpy(pos, str, len);
61
void* sql_memdup(const void* ptr, size_t len)
63
void* pos= sql_alloc(len);
114
69
} /* namespace drizzled */