summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorserg@sergbook.mysql.com <>2005-08-25 00:08:02 +0400
committerserg@sergbook.mysql.com <>2005-08-25 00:08:02 +0400
commit714b27c71c256332f803df5090ed1b8645042141 (patch)
tree7b55868b560cef2962cb095bd8339813ddef9f73 /mysys
parent17654cd7af7f3739d97b68c6b5d00aae7d5dc8ce (diff)
parent909247a95fd5cdaf0162597fae56dbeee3d2ba17 (diff)
downloadmariadb-git-714b27c71c256332f803df5090ed1b8645042141.tar.gz
merged
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_alloc.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index d8c19d86e5c..d52a8efeed2 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -203,7 +203,7 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
next->left= get_size-ALIGN_SIZE(sizeof(USED_MEM));
*prev=next;
}
-
+
point= (gptr) ((char*) next+ (next->size-next->left));
/*TODO: next part may be unneded due to mem_root->first_block_usage counter*/
if ((next->left-= Size) < mem_root->min_malloc)
@@ -217,6 +217,12 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
#endif
}
+#ifdef SAFEMALLOC
+#define TRASH(X) bfill(((char*)(X) + ((X)->size-(X)->left)), (X)->left, 0xa5)
+#else
+#define TRASH /* no-op */
+#endif
+
/* Mark all data in blocks free for reusage */
static inline void mark_blocks_free(MEM_ROOT* root)
@@ -227,14 +233,20 @@ static inline void mark_blocks_free(MEM_ROOT* root)
/* iterate through (partially) free blocks, mark them free */
last= &root->free;
for (next= root->free; next; next= *(last= &next->next))
+ {
next->left= next->size - ALIGN_SIZE(sizeof(USED_MEM));
+ TRASH(next);
+ }
/* Combine the free and the used list */
*last= next=root->used;
/* now go through the used blocks and mark them free */
for (; next; next= next->next)
+ {
next->left= next->size - ALIGN_SIZE(sizeof(USED_MEM));
+ TRASH(next);
+ }
/* Now everything is set; Indicate that nothing is used anymore */
root->used= 0;
@@ -280,6 +292,7 @@ void free_root(MEM_ROOT *root, myf MyFlags)
{
root->free=root->pre_alloc;
root->free->left=root->pre_alloc->size-ALIGN_SIZE(sizeof(USED_MEM));
+ TRASH(root->pre_alloc);
root->free->next=0;
}
root->block_num= 4;