diff options
author | unknown <serg@sergbook.mysql.com> | 2005-08-26 13:24:59 +0400 |
---|---|---|
committer | unknown <serg@sergbook.mysql.com> | 2005-08-26 13:24:59 +0400 |
commit | ad594de473a16b0bb0ba4a9292cf3218cd93ac2c (patch) | |
tree | 02fd091693e67b70f5b80fd94b4b006e1816f41c /mysys/my_alloc.c | |
parent | 9f23fa9549b721aab000b5f04b100a9b6b0ef1c7 (diff) | |
parent | 9e796abb5bcd8215c07936cefd94813b011f2c2f (diff) | |
download | mariadb-git-ad594de473a16b0bb0ba4a9292cf3218cd93ac2c.tar.gz |
merged
mysys/my_alloc.c:
Auto merged
sql/sql_table.cc:
Auto merged
Diffstat (limited to 'mysys/my_alloc.c')
-rw-r--r-- | mysys/my_alloc.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c index 619d6bd5654..5a78eb17c96 100644 --- a/mysys/my_alloc.c +++ b/mysys/my_alloc.c @@ -206,7 +206,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) @@ -221,6 +221,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) @@ -231,14 +237,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; @@ -298,6 +310,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; |