diff options
author | Sergei Golubchik <serg@mariadb.org> | 2018-01-20 17:59:11 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2018-01-22 11:39:54 +0100 |
commit | 22ae3843db6c8b2a84ca5d16cd99025abb52cc27 (patch) | |
tree | 78cd7d2f09ac106939cdfdb81e5677ceb9135e22 | |
parent | 204cb85aab3e6326e9f7a51c478efd6fad44801a (diff) | |
download | mariadb-git-22ae3843db6c8b2a84ca5d16cd99025abb52cc27.tar.gz |
Correct TRASH() macro usage
TRASH was mapped to TRASH_FREE and was supposed to be used for memory
that should not be accessed anymore, while TRASH_ALLOC() is to be
used for uninitialized but to-be-used memory.
But sometimes TRASH() was used in the latter sense.
Remove TRASH() macro, always use explicit TRASH_ALLOC() or TRASH_FREE().
-rw-r--r-- | include/my_valgrind.h | 1 | ||||
-rw-r--r-- | mysys/my_alloc.c | 2 | ||||
-rw-r--r-- | mysys/my_thr_init.c | 2 | ||||
-rw-r--r-- | sql/field.h | 2 | ||||
-rw-r--r-- | sql/item.h | 2 | ||||
-rw-r--r-- | sql/opt_range.cc | 2 | ||||
-rw-r--r-- | sql/sql_cursor.cc | 2 | ||||
-rw-r--r-- | sql/sql_lex.h | 4 | ||||
-rw-r--r-- | sql/sql_lifo_buffer.h | 4 | ||||
-rw-r--r-- | sql/sql_list.h | 4 | ||||
-rw-r--r-- | sql/sql_plugin.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 2 | ||||
-rw-r--r-- | sql/sql_show.cc | 2 | ||||
-rw-r--r-- | sql/sql_string.h | 2 | ||||
-rw-r--r-- | sql/sql_union.cc | 16 | ||||
-rw-r--r-- | sql/table.cc | 2 | ||||
-rw-r--r-- | storage/federatedx/ha_federatedx.h | 2 |
17 files changed, 17 insertions, 36 deletions
diff --git a/include/my_valgrind.h b/include/my_valgrind.h index a9dba1cb06c..6fcc4dfa54a 100644 --- a/include/my_valgrind.h +++ b/include/my_valgrind.h @@ -45,4 +45,3 @@ #endif #define TRASH_ALLOC(A,B) TRASH_FILL(A,B,0xA5) #define TRASH_FREE(A,B) TRASH_FILL(A,B,0x8F) -#define TRASH(A,B) TRASH_FREE(A,B) diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c index 1054db6cee4..d7bc4247556 100644 --- a/mysys/my_alloc.c +++ b/mysys/my_alloc.c @@ -293,7 +293,7 @@ void *multi_alloc_root(MEM_ROOT *root, ...) DBUG_RETURN((void*) start); } -#define TRASH_MEM(X) TRASH(((char*)(X) + ((X)->size-(X)->left)), (X)->left) +#define TRASH_MEM(X) TRASH_FREE(((char*)(X) + ((X)->size-(X)->left)), (X)->left) /* Mark all data in blocks free for reusage */ diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index aefd3564185..55ee1db657e 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -423,8 +423,6 @@ void my_thread_end(void) if (--THR_thread_count == 0) mysql_cond_signal(&THR_COND_threads); mysql_mutex_unlock(&THR_LOCK_threads); - - TRASH(tmp, sizeof(*tmp)); free(tmp); } } diff --git a/sql/field.h b/sql/field.h index f8fc7427618..d484b31d682 100644 --- a/sql/field.h +++ b/sql/field.h @@ -208,7 +208,7 @@ class Field public: static void *operator new(size_t size) throw () { return sql_alloc(size); } - static void operator delete(void *ptr_arg, size_t size) { TRASH(ptr_arg, size); } + static void operator delete(void *ptr_arg, size_t size) { TRASH_FREE(ptr_arg, size); } uchar *ptr; // Position to field in record /** diff --git a/sql/item.h b/sql/item.h index e01cf5384b9..4daca60f68e 100644 --- a/sql/item.h +++ b/sql/item.h @@ -580,7 +580,7 @@ public: { return sql_alloc(size); } static void *operator new(size_t size, MEM_ROOT *mem_root) throw () { return alloc_root(mem_root, size); } - static void operator delete(void *ptr,size_t size) { TRASH(ptr, size); } + static void operator delete(void *ptr,size_t size) { TRASH_FREE(ptr, size); } static void operator delete(void *ptr, MEM_ROOT *mem_root) {} enum Type {FIELD_ITEM= 0, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM, diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 25a9e729a8b..04ab8415dfe 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2651,7 +2651,7 @@ public: /* Table read plans are allocated on MEM_ROOT and are never deleted */ static void *operator new(size_t size, MEM_ROOT *mem_root) { return (void*) alloc_root(mem_root, (uint) size); } - static void operator delete(void *ptr,size_t size) { TRASH(ptr, size); } + static void operator delete(void *ptr,size_t size) { TRASH_FREE(ptr, size); } static void operator delete(void *ptr, MEM_ROOT *mem_root) { /* Never called */ } virtual ~TABLE_READ_PLAN() {} /* Remove gcc warning */ diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc index 230a8b2c802..f7ffd86fe83 100644 --- a/sql/sql_cursor.cc +++ b/sql/sql_cursor.cc @@ -187,7 +187,7 @@ void Server_side_cursor::operator delete(void *ptr, size_t size) MEM_ROOT own_root= *cursor->mem_root; DBUG_ENTER("Server_side_cursor::operator delete"); - TRASH(ptr, size); + TRASH_FREE(ptr, size); /* If this cursor has never been opened mem_root is empty. Otherwise mem_root points to the memory the cursor object was allocated in. diff --git a/sql/sql_lex.h b/sql/sql_lex.h index cf34c567626..57129cfedc7 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -548,7 +548,7 @@ public: } static void *operator new(size_t size, MEM_ROOT *mem_root) throw () { return (void*) alloc_root(mem_root, (uint) size); } - static void operator delete(void *ptr,size_t size) { TRASH(ptr, size); } + static void operator delete(void *ptr,size_t size) { TRASH_FREE(ptr, size); } static void operator delete(void *ptr, MEM_ROOT *mem_root) {} // Ensures that at least all members used during cleanup() are initialized. @@ -2949,7 +2949,7 @@ struct st_lex_local: public LEX return (void*) alloc_root(mem_root, (uint) size); } static void operator delete(void *ptr,size_t size) - { TRASH(ptr, size); } + { TRASH_FREE(ptr, size); } static void operator delete(void *ptr, MEM_ROOT *mem_root) { /* Never called */ } }; diff --git a/sql/sql_lifo_buffer.h b/sql/sql_lifo_buffer.h index feec4aeb4c2..f551cc48c23 100644 --- a/sql/sql_lifo_buffer.h +++ b/sql/sql_lifo_buffer.h @@ -84,7 +84,7 @@ public: start= start_arg; end= end_arg; if (end != start) - TRASH(start, end - start); + TRASH_ALLOC(start, end - start); reset(); } @@ -224,7 +224,7 @@ public: { DBUG_ASSERT(unused_end >= unused_start); DBUG_ASSERT(end == unused_start); - TRASH(unused_start, unused_end - unused_start); + TRASH_ALLOC(unused_start, unused_end - unused_start); end= unused_end; } /* Return pointer to start of the memory area that is occupied by the data */ diff --git a/sql/sql_list.h b/sql/sql_list.h index 7538f69766d..08667bed02a 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -41,12 +41,12 @@ public: { return alloc_root(mem_root, size); } static void *operator new(size_t size, MEM_ROOT *mem_root) throw () { return alloc_root(mem_root, size); } - static void operator delete(void *ptr, size_t size) { TRASH(ptr, size); } + static void operator delete(void *ptr, size_t size) { TRASH_FREE(ptr, size); } static void operator delete(void *ptr, MEM_ROOT *mem_root) { /* never called */ } static void operator delete[](void *ptr, MEM_ROOT *mem_root) { /* never called */ } - static void operator delete[](void *ptr, size_t size) { TRASH(ptr, size); } + static void operator delete[](void *ptr, size_t size) { TRASH_FREE(ptr, size); } #ifdef HAVE_valgrind bool dummy; inline Sql_alloc() :dummy(0) {} diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index ccefb04451c..e616b0a09e4 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -267,7 +267,7 @@ public: static void *operator new(size_t size, MEM_ROOT *mem_root) { return (void*) alloc_root(mem_root, size); } static void operator delete(void *ptr_arg,size_t size) - { TRASH(ptr_arg, size); } + { TRASH_FREE(ptr_arg, size); } sys_var_pluginvar(sys_var_chain *chain, const char *name_arg, struct st_mysql_sys_var *plugin_var_arg, diff --git a/sql/sql_select.cc b/sql/sql_select.cc index d35a5a8094c..f7624b2b56c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -11530,7 +11530,7 @@ public: } static void operator delete(void *ptr __attribute__((unused)), size_t size __attribute__((unused))) - { TRASH(ptr, size); } + { TRASH_FREE(ptr, size); } Item *and_level; Item_func *cmp_func; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 8789f0c9f24..06d5a6f570a 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2111,7 +2111,7 @@ public: } static void operator delete(void *ptr __attribute__((unused)), size_t size __attribute__((unused))) - { TRASH(ptr, size); } + { TRASH_FREE(ptr, size); } ulong thread_id; time_t start_time; diff --git a/sql/sql_string.h b/sql/sql_string.h index 1fce3ae6c6f..3175a6616bf 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -102,7 +102,7 @@ public: { (void) ptr_arg; (void) size; - TRASH(ptr_arg, size); + TRASH_FREE(ptr_arg, size); } static void operator delete(void *, MEM_ROOT *) { /* never called */ } diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 2d816e0309d..bbb4133417e 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -935,22 +935,6 @@ bool st_select_lex_unit::cleanup() void st_select_lex_unit::reinit_exec_mechanism() { prepared= optimized= executed= 0; -#ifndef DBUG_OFF - if (is_union()) - { - List_iterator_fast<Item> it(item_list); - Item *field; - while ((field= it++)) - { - /* - we can't cleanup here, because it broke link to temporary table field, - but have to drop fixed flag to allow next fix_field of this field - during re-executing - */ - field->fixed= 0; - } - } -#endif } diff --git a/sql/table.cc b/sql/table.cc index 9cade76cb78..6795621b719 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3991,7 +3991,7 @@ void TABLE::init(THD *thd, TABLE_LIST *tl) DBUG_ASSERT(key_read == 0); /* mark the record[0] uninitialized */ - TRASH(record[0], s->reclength); + TRASH_ALLOC(record[0], s->reclength); /* Initialize the null marker bits, to ensure that if we are doing a read diff --git a/storage/federatedx/ha_federatedx.h b/storage/federatedx/ha_federatedx.h index 1c64892418e..9529cb126e7 100644 --- a/storage/federatedx/ha_federatedx.h +++ b/storage/federatedx/ha_federatedx.h @@ -169,7 +169,7 @@ public: static void *operator new(size_t size, MEM_ROOT *mem_root) throw () { return alloc_root(mem_root, size); } static void operator delete(void *ptr, size_t size) - { TRASH(ptr, size); } + { TRASH_FREE(ptr, size); } virtual int query(const char *buffer, uint length)=0; virtual FEDERATEDX_IO_RESULT *store_result()=0; |