13
13
along with this program; if not, write to the Free Software
14
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
18
* @brief Memory root declarations
17
21
#ifndef DRIZZLED_MEMORY_ROOT_H
18
22
#define DRIZZLED_MEMORY_ROOT_H
53
/* blocks with free memory in it */
68
Root(size_t block_size_arg)
70
free= used= pre_alloc= 0;
72
block_size= block_size_arg - memory::ROOT_MIN_BLOCK_SIZE;
74
block_num= 4; /* We shift this with >>2 */
79
* blocks with free memory in it
54
81
internal::UsedMemory *free;
56
/* blocks almost without free memory */
84
* blocks almost without free memory
57
86
internal::UsedMemory *used;
59
/* preallocated block */
60
91
internal::UsedMemory *pre_alloc;
62
/* if block have less memory it will be put in 'used' list */
94
* if block have less memory it will be put in 'used' list
64
size_t block_size; /* initial block size */
65
unsigned int block_num; /* allocated blocks counter */
67
first free block in queue test counter (if it exceed
68
MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list)
98
size_t block_size; ///< initial block size
99
unsigned int block_num; ///< allocated blocks counter
102
* first free block in queue test counter (if it exceed
103
* MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list)
70
105
unsigned int first_block_usage;
72
107
void (*error_handler)(void);
108
void reset_root_defaults(size_t block_size, size_t prealloc_size);
109
void *alloc_root(size_t Size);
110
void mark_blocks_free();
111
void *memdup_root(const void *str, size_t len);
112
char *strdup_root(const char *str);
113
char *strmake_root(const char *str,size_t len);
114
void init_alloc_root(size_t block_size= ROOT_MIN_BLOCK_SIZE);
116
inline bool alloc_root_inited()
118
return min_malloc != 0;
120
void free_root(myf MyFLAGS);
121
void *multi_alloc_root(int unused, ...);
75
inline static bool alloc_root_inited(Root *root)
77
return root->min_malloc != 0;
80
void init_alloc_root(Root *mem_root,
81
size_t block_size= ROOT_MIN_BLOCK_SIZE);
82
void *alloc_root(Root *mem_root, size_t Size);
83
void *multi_alloc_root(Root *mem_root, ...);
84
void free_root(Root *root, myf MyFLAGS);
85
void set_prealloc_root(Root *root, char *ptr);
86
void reset_root_defaults(Root *mem_root, size_t block_size,
87
size_t prealloc_size);
88
char *strdup_root(Root *root,const char *str);
89
char *strmake_root(Root *root,const char *str,size_t len);
90
void *memdup_root(Root *root,const void *str, size_t len);
92
125
} /* namespace memory */
93
126
} /* namespace drizzled */