Commit 80f2abc5 authored by Brandon Nesterenko's avatar Brandon Nesterenko

MDEV-34348: Fix sql_list.h add_unique

Made base_list::add_unique templated, with a default
type of void (to adhere to existing uses), and then
the already templated class List can then be specific
about what types it will use in the provided comparator
function.
parent d586247e
......@@ -129,8 +129,6 @@ struct list_node :public Sql_alloc
}
};
typedef bool List_eq(void *a, void *b);
extern MYSQL_PLUGIN_IMPORT list_node end_of_list;
class base_list :public Sql_alloc
......@@ -301,11 +299,12 @@ class base_list :public Sql_alloc
inline void **head_ref() { return first != &end_of_list ? &first->info : 0; }
inline bool is_empty() { return first == &end_of_list ; }
inline list_node *last_ref() { return &end_of_list; }
inline bool add_unique(void *info, List_eq *eq)
template <typename T= void>
inline bool add_unique(T *info, bool (*eq)(T *a, T *b))
{
list_node *node= first;
for (;
node != &end_of_list && (!(*eq)(node->info, info));
node != &end_of_list && (!(*eq)((T *) node->info, info));
node= node->next) ;
if (node == &end_of_list)
return push_back(info);
......@@ -513,7 +512,7 @@ template <class T> class List :public base_list
inline void prepend(List<T> *list) { base_list::prepend(list); }
inline void disjoin(List<T> *list) { base_list::disjoin(list); }
inline bool add_unique(T *a, bool (*eq)(T *a, T *b))
{ return base_list::add_unique(a, (List_eq *)eq); }
{ return base_list::add_unique<T>(a, eq); }
inline bool copy(const List<T> *list, MEM_ROOT *root)
{ return base_list::copy(list, root); }
void delete_elements(void)
......
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