18
18
* @brief Memory root declarations
21
#ifndef DRIZZLED_MEMORY_ROOT_H
22
#define DRIZZLED_MEMORY_ROOT_H
23
#include <drizzled/common_fwd.h>
26
24
#include <drizzled/definitions.h>
25
#include <drizzled/visibility.h>
32
30
* @namespace drizzled::memory
36
34
* comment on the namespace Doxygen won't extract any documentation for
37
35
* namespace members.
42
39
static const int KEEP_PREALLOC= 1;
43
40
/* move used to free list and reuse them */
44
41
static const int MARK_BLOCKS_FREE= 2;
50
{ /* struct for once_alloc (block) */
52
UsedMemory *next; /* Next block in use */
53
size_t left; /* memory left in block */
54
size_t size; /* size of block */
46
{ /* struct for once_alloc (block) */
48
UsedMemory *next; /* Next block in use */
49
size_t left; /* memory left in block */
50
size_t size; /* size of block */
59
54
static const size_t ROOT_MIN_BLOCK_SIZE= (MALLOC_OVERHEAD + sizeof(internal::UsedMemory) + 8);
56
class DRIZZLED_API Root
117
105
unsigned int first_block_usage;
119
void (*error_handler)(void);
120
void reset_root_defaults(size_t block_size, size_t prealloc_size);
121
void *alloc_root(size_t Size);
107
void reset_defaults(size_t block_size, size_t prealloc_size);
108
unsigned char* alloc(size_t Size);
122
109
void mark_blocks_free();
123
void *memdup_root(const void *str, size_t len);
124
char *strdup_root(const char *str);
125
char *strmake_root(const char *str,size_t len);
126
void init_alloc_root(size_t block_size= ROOT_MIN_BLOCK_SIZE);
110
void* memdup(const void*, size_t);
111
char* strdup(const char*);
113
char* strmake(const char*, size_t);
114
char* strmake(const std::string&);
115
char* strmake(const String&);
116
void init(size_t block_size= ROOT_MIN_BLOCK_SIZE);
128
118
inline bool alloc_root_inited()
130
120
return min_malloc != 0;
132
122
void free_root(myf MyFLAGS);
133
void *multi_alloc_root(int unused, ...);
123
void* multi_alloc(int unused, ...);
125
void* calloc(size_t size)
127
void* ptr= alloc(size);
128
memset(ptr, 0, size);
136
133
} /* namespace memory */
137
134
} /* namespace drizzled */
139
#endif /* DRIZZLED_MEMORY_ROOT_H */
136
inline void* operator new(size_t size, drizzled::memory::Root& root)
138
return root.alloc(size);
141
inline void* operator new[](size_t size, drizzled::memory::Root& root)
143
return root.alloc(size);