34
34
/* move used to free list and reuse them */
35
35
static const int MARK_BLOCKS_FREE= 2;
40
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
41
#define ALLOC_MAX_BLOCK_TO_DROP 4096
42
#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10
44
typedef struct st_used_mem
45
{ /* struct for once_alloc (block) */
46
struct st_used_mem *next; /* Next block in use */
47
size_t left; /* memory left in block */
48
size_t size; /* size of block */
41
{ /* struct for once_alloc (block) */
43
UsedMemory *next; /* Next block in use */
44
size_t left; /* memory left in block */
45
size_t size; /* size of block */
50
static const size_t ROOT_MIN_BLOCK_SIZE= (MALLOC_OVERHEAD + sizeof(internal::UsedMemory) + 8);
52
57
typedef struct st_mem_root
54
USED_MEM *free; /* blocks with free memory in it */
55
USED_MEM *used; /* blocks almost without free memory */
56
USED_MEM *pre_alloc; /* preallocated block */
59
/* blocks with free memory in it */
60
drizzled::memory::internal::UsedMemory *free;
62
/* blocks almost without free memory */
63
drizzled::memory::internal::UsedMemory *used;
65
/* preallocated block */
66
drizzled::memory::internal::UsedMemory *pre_alloc;
57
68
/* if block have less memory it will be put in 'used' list */
59
70
size_t block_size; /* initial block size */
72
83
return root->min_malloc != 0;
75
void init_alloc_root(MEM_ROOT *mem_root, size_t block_size,
76
size_t pre_alloc_size);
86
void init_alloc_root(MEM_ROOT *mem_root,
87
size_t block_size= drizzled::memory::ROOT_MIN_BLOCK_SIZE);
77
88
void *alloc_root(MEM_ROOT *mem_root, size_t Size);
78
89
void *multi_alloc_root(MEM_ROOT *mem_root, ...);
79
90
void free_root(MEM_ROOT *root, myf MyFLAGS);