Skip to content

Commit

Permalink
MDEV-16904 inline void swap(base_list &rhs) should swap list only whe…
Browse files Browse the repository at this point in the history
…n list is...

not empty

We should swap the list only when list is not empty.
  • Loading branch information
mariadb-SachinSetiya committed Aug 7, 2018
1 parent ebaacf0 commit ad57709
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sql/sql_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,13 @@ class base_list :public Sql_alloc
*/
inline void swap(base_list &rhs)
{
list_node **rhs_last=rhs.last;
swap_variables(list_node *, first, rhs.first);
swap_variables(list_node **, last, rhs.last);
swap_variables(uint, elements, rhs.elements);
rhs.last= last == &first ? &rhs.first : last;
last = rhs_last == &rhs.first ? &first : rhs_last;
}

inline list_node* last_node() { return *last; }
inline list_node* first_node() { return first;}
inline void *head() { return first->info; }
Expand Down

0 comments on commit ad57709

Please sign in to comment.