12
12
You should have received a copy of the GNU General Public License
13
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
18
* @brief Memory root declarations
21
17
#ifndef DRIZZLED_MEMORY_ROOT_H
22
18
#define DRIZZLED_MEMORY_ROOT_H
78
Root(size_t block_size_arg)
80
free= used= pre_alloc= 0;
82
block_size= block_size_arg - memory::ROOT_MIN_BLOCK_SIZE;
83
block_num= 4; /* We shift this with >>2 */
91
* blocks with free memory in it
57
/* blocks with free memory in it */
93
58
internal::UsedMemory *free;
96
* blocks almost without free memory
60
/* blocks almost without free memory */
98
61
internal::UsedMemory *used;
63
/* preallocated block */
103
64
internal::UsedMemory *pre_alloc;
106
* if block have less memory it will be put in 'used' list
66
/* if block have less memory it will be put in 'used' list */
108
67
size_t min_malloc;
110
size_t block_size; ///< initial block size
111
unsigned int block_num; ///< allocated blocks counter
114
* first free block in queue test counter (if it exceed
115
* MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list)
68
size_t block_size; /* initial block size */
69
unsigned int block_num; /* allocated blocks counter */
71
first free block in queue test counter (if it exceed
72
MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list)
117
74
unsigned int first_block_usage;
119
76
void (*error_handler)(void);
120
void reset_root_defaults(size_t block_size, size_t prealloc_size);
121
void *alloc_root(size_t Size);
122
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);
128
inline bool alloc_root_inited()
130
return min_malloc != 0;
132
void free_root(myf MyFLAGS);
133
void *multi_alloc_root(int unused, ...);
136
} /* namespace memory */
137
} /* namespace drizzled */
79
inline static bool alloc_root_inited(Root *root)
81
return root->min_malloc != 0;
84
void init_alloc_root(Root *mem_root,
85
size_t block_size= ROOT_MIN_BLOCK_SIZE);
86
void *alloc_root(Root *mem_root, size_t Size);
87
void *multi_alloc_root(Root *mem_root, ...);
88
void free_root(Root *root, myf MyFLAGS);
89
void set_prealloc_root(Root *root, char *ptr);
90
void reset_root_defaults(Root *mem_root, size_t block_size,
91
size_t prealloc_size);
92
char *strdup_root(Root *root,const char *str);
93
char *strmake_root(Root *root,const char *str,size_t len);
94
void *memdup_root(Root *root,const void *str, size_t len);
99
#if defined(__cplusplus)
139
102
#endif /* DRIZZLED_MEMORY_ROOT_H */