diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 0271a765fc43..a566c9e1567d 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -2705,11 +2705,8 @@ void ha_rocksdb::load_auto_incr_value() (Why don't we use index_init/index_end? class handler defines index_init as private, for some reason). */ - if (scan_it) - { - delete scan_it; - scan_it= NULL; - } + delete scan_it; + scan_it= NULL; } @@ -3403,44 +3400,34 @@ int ha_rocksdb::close(void) pk_descr= NULL; key_descr= NULL; - if (pk_tuple) - my_free(pk_tuple); + my_free(pk_tuple); pk_tuple= NULL; - if (pk_packed_tuple) - my_free(pk_packed_tuple); + my_free(pk_packed_tuple); pk_packed_tuple= NULL; - if (sec_key_packed_tuple) - my_free(sec_key_packed_tuple); + my_free(sec_key_packed_tuple); sec_key_packed_tuple= NULL; - if (sec_key_match_prefix_buf) - my_free(sec_key_match_prefix_buf); + my_free(sec_key_match_prefix_buf); sec_key_match_prefix_buf= NULL; - if (sec_key_packed_tuple_old) - my_free(sec_key_packed_tuple_old); + my_free(sec_key_packed_tuple_old); sec_key_packed_tuple_old= NULL; - if (end_key_packed_tuple) - my_free(end_key_packed_tuple); + my_free(end_key_packed_tuple); end_key_packed_tuple= NULL; - if (sec_key_tails) - my_free(sec_key_tails); + my_free(sec_key_tails); sec_key_tails= NULL; - if (sec_key_tails_old) - my_free(sec_key_tails_old); + my_free(sec_key_tails_old); sec_key_tails_old= NULL; - if (pack_buffer) - my_free(pack_buffer); + my_free(pack_buffer); pack_buffer= NULL; - if (field_enc) - my_free(field_enc); + my_free(field_enc); field_enc= NULL; DBUG_RETURN(free_share(share)); @@ -3636,6 +3623,7 @@ int ha_rocksdb::create_key_defs(TABLE *table_arg, const char *db_table, error: /* Delete what we have allocated so far */ delete tbl_def; + tbl_def = nullptr; DBUG_RETURN(HA_ERR_INTERNAL_ERROR); } @@ -5702,11 +5690,9 @@ int ha_rocksdb::rnd_end() { DBUG_ENTER("ha_rocksdb::rnd_end"); - if (scan_it) - { - delete scan_it; - scan_it= NULL; - } + delete scan_it; + scan_it= NULL; + DBUG_RETURN(0); } @@ -5726,12 +5712,8 @@ int ha_rocksdb::index_init(uint idx, bool sorted) int ha_rocksdb::index_end() { - - if (scan_it) - { - delete scan_it; - scan_it= NULL; - } + delete scan_it; + scan_it= NULL; active_index= MAX_KEY; in_range_check_pushed_down= FALSE; diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc index 68dd0b56e1e3..1b7f39eebfa9 100644 --- a/storage/rocksdb/rdb_datadic.cc +++ b/storage/rocksdb/rdb_datadic.cc @@ -155,10 +155,11 @@ RDBSE_KEYDEF::~RDBSE_KEYDEF() { mysql_mutex_destroy(&mutex); - if (pk_part_no) - my_free(pk_part_no); - if (pack_info) - my_free(pack_info); + my_free(pk_part_no); + pk_part_no = nullptr; + + my_free(pack_info); + pack_info = nullptr; } void RDBSE_KEYDEF::setup(TABLE *tbl) @@ -1466,9 +1467,13 @@ RDBSE_TABLE_DEF::~RDBSE_TABLE_DEF() if (ddl_manager && key_descr[i]) { ddl_manager->erase_index_num(key_descr[i]->get_gl_index_id()); } + delete key_descr[i]; + key_descr[i] = nullptr; } + delete[] key_descr; + key_descr = nullptr; } } diff --git a/storage/rocksdb/rdb_locks.cc b/storage/rocksdb/rdb_locks.cc index 75808f846986..98f5b726f634 100644 --- a/storage/rocksdb/rdb_locks.cc +++ b/storage/rocksdb/rdb_locks.cc @@ -18,12 +18,9 @@ #pragma implementation // gcc: Class implementation #endif -#include - -#include "ha_rocksdb.h" // TODO: this is too much - #include "rdb_locks.h" +#include typedef struct { @@ -306,8 +303,8 @@ Row_lock* LockTable::get_lock(LF_PINS *pins, const uchar* key, size_t keylen, locked= do_locking_action(pins, found_lock, timeout_sec, is_write_lock); err: - if (key_copy) - my_free(key_copy); + my_free(key_copy); + key_copy = nullptr; return locked? found_lock->get_lock_handle(is_write_lock) : NULL; } @@ -469,6 +466,7 @@ bool LockTable::do_locking_action(LF_PINS *pins, Row_lock_impl *found_lock, res= lf_hash_delete(&lf_hash, pins, found_lock->rowkey, found_lock->len); DBUG_ASSERT(res == 0); my_free(rowkey); + rowkey = nullptr; } } @@ -579,6 +577,7 @@ void LockTable::release_lock(LF_PINS *pins, Row_lock *own_lock_handle) res= lf_hash_delete(&lf_hash, pins, own_lock->rowkey, own_lock->len); DBUG_ASSERT(res == 0); my_free(rowkey); + rowkey = nullptr; } else {