Skip to content

Commit

Permalink
remove unneeded allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgs authored and Sergey Vojtovich committed Sep 14, 2017
1 parent 46cf221 commit c8cba4a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
11 changes: 3 additions & 8 deletions sql/ha_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,8 @@ bool Partition_share::init(uint num_parts)
auto_inc_initialized= false;
partition_name_hash_initialized= false;
next_auto_inc_val= 0;
partitions_share_refs= new Parts_share_refs;
if (!partitions_share_refs)
DBUG_RETURN(true);
if (partitions_share_refs->init(num_parts))
if (partitions_share_refs.init(num_parts))
{
delete partitions_share_refs;
DBUG_RETURN(true);
}
DBUG_RETURN(false);
Expand Down Expand Up @@ -3305,9 +3301,8 @@ bool ha_partition::set_ha_share_ref(Handler_share **ha_share_arg)
DBUG_RETURN(true);
if (!(part_share= get_share()))
DBUG_RETURN(true);
DBUG_ASSERT(part_share->partitions_share_refs);
DBUG_ASSERT(part_share->partitions_share_refs->num_parts >= m_tot_parts);
ha_shares= part_share->partitions_share_refs->ha_shares;
DBUG_ASSERT(part_share->partitions_share_refs.num_parts >= m_tot_parts);
ha_shares= part_share->partitions_share_refs.ha_shares;
for (i= 0; i < m_tot_parts; i++)
{
if (m_file[i]->set_ha_share_ref(&ha_shares[i]))
Expand Down
10 changes: 3 additions & 7 deletions sql/ha_partition.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ class Parts_share_refs
{
uint i;
for (i= 0; i < num_parts; i++)
if (ha_shares[i])
delete ha_shares[i];
if (ha_shares)
delete [] ha_shares;
delete ha_shares[i];
delete[] ha_shares;
}
bool init(uint arg_num_parts)
{
Expand Down Expand Up @@ -86,16 +84,14 @@ class Partition_share : public Handler_share
bool partition_name_hash_initialized;
HASH partition_name_hash;
/** Storage for each partitions Handler_share */
Parts_share_refs *partitions_share_refs;
Parts_share_refs partitions_share_refs;
Partition_share() {}
~Partition_share()
{
DBUG_ENTER("Partition_share::~Partition_share");
mysql_mutex_destroy(&auto_inc_mutex);
if (partition_name_hash_initialized)
my_hash_free(&partition_name_hash);
if (partitions_share_refs)
delete partitions_share_refs;
DBUG_VOID_RETURN;
}
bool init(uint num_parts);
Expand Down

0 comments on commit c8cba4a

Please sign in to comment.