|
22 | 22 | #undef EXTRA_DEBUG
|
23 | 23 | #define EXTRA_DEBUG
|
24 | 24 |
|
| 25 | +#define TRASH_MEM(X) TRASH_FREE(((char*)(X) + ((X)->size-(X)->left)), (X)->left) |
| 26 | + |
25 | 27 | /*
|
26 | 28 | Initialize memory root
|
27 | 29 |
|
@@ -60,12 +62,13 @@ void init_alloc_root(MEM_ROOT *mem_root, size_t block_size,
|
60 | 62 | if (pre_alloc_size)
|
61 | 63 | {
|
62 | 64 | if ((mem_root->free= mem_root->pre_alloc=
|
63 |
| - (USED_MEM*) my_malloc(pre_alloc_size+ ALIGN_SIZE(sizeof(USED_MEM)), |
| 65 | + (USED_MEM*) my_malloc(pre_alloc_size + ALIGN_SIZE(sizeof(USED_MEM)), |
64 | 66 | MYF(0))))
|
65 | 67 | {
|
66 | 68 | mem_root->free->size= pre_alloc_size+ALIGN_SIZE(sizeof(USED_MEM));
|
67 | 69 | mem_root->free->left= pre_alloc_size;
|
68 | 70 | mem_root->free->next= 0;
|
| 71 | + TRASH_MEM(mem_root->free); |
69 | 72 | }
|
70 | 73 | }
|
71 | 74 | #endif
|
@@ -132,6 +135,7 @@ void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
|
132 | 135 | mem->left= pre_alloc_size;
|
133 | 136 | mem->next= *prev;
|
134 | 137 | *prev= mem_root->pre_alloc= mem;
|
| 138 | + TRASH_MEM(mem); |
135 | 139 | }
|
136 | 140 | else
|
137 | 141 | {
|
@@ -225,6 +229,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
|
225 | 229 | next->size= get_size;
|
226 | 230 | next->left= get_size-ALIGN_SIZE(sizeof(USED_MEM));
|
227 | 231 | *prev=next;
|
| 232 | + TRASH_MEM(next); |
228 | 233 | }
|
229 | 234 |
|
230 | 235 | point= (uchar*) ((char*) next+ (next->size-next->left));
|
@@ -293,8 +298,6 @@ void *multi_alloc_root(MEM_ROOT *root, ...)
|
293 | 298 | DBUG_RETURN((void*) start);
|
294 | 299 | }
|
295 | 300 |
|
296 |
| -#define TRASH_MEM(X) TRASH_FREE(((char*)(X) + ((X)->size-(X)->left)), (X)->left) |
297 |
| - |
298 | 301 | /* Mark all data in blocks free for reusage */
|
299 | 302 |
|
300 | 303 | static inline void mark_blocks_free(MEM_ROOT* root)
|
|
0 commit comments