Commit ad577091 authored by Sachin's avatar Sachin

MDEV-16904 inline void swap(base_list &rhs) should swap list only when list is...

not empty

We should swap the list only when list is not empty.
parent ebaacf07
...@@ -306,10 +306,13 @@ class base_list :public Sql_alloc ...@@ -306,10 +306,13 @@ class base_list :public Sql_alloc
*/ */
inline void swap(base_list &rhs) inline void swap(base_list &rhs)
{ {
list_node **rhs_last=rhs.last;
swap_variables(list_node *, first, rhs.first); swap_variables(list_node *, first, rhs.first);
swap_variables(list_node **, last, rhs.last);
swap_variables(uint, elements, rhs.elements); 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* last_node() { return *last; }
inline list_node* first_node() { return first;} inline list_node* first_node() { return first;}
inline void *head() { return first->info; } inline void *head() { return first->info; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment