summaryrefslogtreecommitdiff
path: root/sql/sql_list.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_list.cc')
-rw-r--r--sql/sql_list.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/sql/sql_list.cc b/sql/sql_list.cc
index 01ab9b91424..49b649133d0 100644
--- a/sql/sql_list.cc
+++ b/sql/sql_list.cc
@@ -36,3 +36,37 @@ void free_list(I_List <i_string> *list)
while ((tmp= list->get()))
delete tmp;
}
+
+
+base_list::base_list(const base_list &rhs, MEM_ROOT *mem_root)
+{
+ if (rhs.elements)
+ {
+ /*
+ It's okay to allocate an array of nodes at once: we never
+ call a destructor for list_node objects anyway.
+ */
+ first= (list_node*) alloc_root(mem_root,
+ sizeof(list_node) * rhs.elements);
+ if (first)
+ {
+ elements= rhs.elements;
+ list_node *dst= first;
+ list_node *src= rhs.first;
+ for (; dst < first + elements - 1; dst++, src= src->next)
+ {
+ dst->info= src->info;
+ dst->next= dst + 1;
+ }
+ /* Copy the last node */
+ dst->info= src->info;
+ dst->next= &end_of_list;
+ /* Setup 'last' member */
+ last= &dst->next;
+ return;
+ }
+ }
+ elements= 0;
+ first= &end_of_list;
+ last= &first;
+}