mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / sql / sql_list.cc
blob9b8ec5c5742b9d3f519a0e54e49d985a20cc20a9
1 /* Copyright (c) 2000, 2001, 2003, 2005-2007 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
17 #ifdef USE_PRAGMA_IMPLEMENTATION
18 #pragma implementation // gcc: Class implementation
19 #endif
21 #include "mysql_priv.h"
23 list_node end_of_list;
25 void free_list(I_List <i_string_pair> *list)
27 i_string_pair *tmp;
28 while ((tmp= list->get()))
29 delete tmp;
33 void free_list(I_List <i_string> *list)
35 i_string *tmp;
36 while ((tmp= list->get()))
37 delete tmp;
41 base_list::base_list(const base_list &rhs, MEM_ROOT *mem_root)
43 if (rhs.elements)
46 It's okay to allocate an array of nodes at once: we never
47 call a destructor for list_node objects anyway.
49 first= (list_node*) alloc_root(mem_root,
50 sizeof(list_node) * rhs.elements);
51 if (first)
53 elements= rhs.elements;
54 list_node *dst= first;
55 list_node *src= rhs.first;
56 for (; dst < first + elements - 1; dst++, src= src->next)
58 dst->info= src->info;
59 dst->next= dst + 1;
61 /* Copy the last node */
62 dst->info= src->info;
63 dst->next= &end_of_list;
64 /* Setup 'last' member */
65 last= &dst->next;
66 return;
69 elements= 0;
70 first= &end_of_list;
71 last= &first;