1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-28576 Ability to manipulate List<const char *>

For "const char *" replace() and after() accepted const as "T *" and
passed forward "void *". This cannot be cast implicitly, so we better
use "const void *" instead of "void *" in the input interface. This
way we avoid problems with using List for any const type.
This commit is contained in:
Aleksey Midenkov
2022-10-05 17:46:50 +03:00
parent c0eda62aec
commit 4eb8c35b36

View File

@ -118,8 +118,8 @@ struct list_node :public Sql_alloc
{ {
list_node *next; list_node *next;
void *info; void *info;
list_node(void *info_par,list_node *next_par) list_node(const void *info_par, list_node *next_par)
:next(next_par),info(info_par) :next(next_par), info(const_cast<void *>(info_par))
{} {}
list_node() /* For end_of_list */ list_node() /* For end_of_list */
{ {
@ -384,7 +384,7 @@ public:
#endif // LIST_EXTRA_DEBUG #endif // LIST_EXTRA_DEBUG
protected: protected:
void after(void *info,list_node *node) void after(const void *info, list_node *node)
{ {
list_node *new_node=new list_node(info,node->next); list_node *new_node=new list_node(info,node->next);
node->next=new_node; node->next=new_node;
@ -445,11 +445,11 @@ public:
{ {
el= &list->first; el= &list->first;
} }
inline void *replace(void *element) inline void *replace(const void *element)
{ // Return old element { // Return old element
void *tmp=current->info; void *tmp=current->info;
DBUG_ASSERT(current->info != 0); DBUG_ASSERT(current->info != 0);
current->info=element; current->info= const_cast<void *>(element);
return tmp; return tmp;
} }
void *replace(base_list &new_list) void *replace(base_list &new_list)
@ -472,7 +472,7 @@ public:
el=prev; el=prev;
current=0; // Safeguard current=0; // Safeguard
} }
void after(void *element) // Insert element after current void after(const void *element) // Insert element after current
{ {
list->after(element,current); list->after(element,current);
current=current->next; current=current->next;