1
by brian
clean slate |
1 |
/* Copyright (C) 2000-2001, 2003, 2005 MySQL AB
|
2 |
||
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.
|
|
6 |
||
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.
|
|
11 |
||
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
15 |
||
16 |
||
17 |
#ifdef USE_PRAGMA_IMPLEMENTATION
|
|
18 |
#pragma implementation // gcc: Class implementation |
|
19 |
#endif
|
|
20 |
||
21 |
#include "mysql_priv.h" |
|
22 |
||
23 |
list_node end_of_list; |
|
24 |
||
25 |
void free_list(I_List <i_string_pair> *list) |
|
26 |
{
|
|
27 |
i_string_pair *tmp; |
|
28 |
while ((tmp= list->get())) |
|
29 |
delete tmp; |
|
30 |
}
|
|
31 |
||
32 |
||
33 |
void free_list(I_List <i_string> *list) |
|
34 |
{
|
|
35 |
i_string *tmp; |
|
36 |
while ((tmp= list->get())) |
|
37 |
delete tmp; |
|
38 |
}
|
|
39 |
||
40 |
||
41 |
base_list::base_list(const base_list &rhs, MEM_ROOT *mem_root) |
|
42 |
{
|
|
43 |
if (rhs.elements) |
|
44 |
{
|
|
45 |
/*
|
|
46 |
It's okay to allocate an array of nodes at once: we never
|
|
47 |
call a destructor for list_node objects anyway.
|
|
48 |
*/
|
|
49 |
first= (list_node*) alloc_root(mem_root, |
|
50 |
sizeof(list_node) * rhs.elements); |
|
51 |
if (first) |
|
52 |
{
|
|
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) |
|
57 |
{
|
|
58 |
dst->info= src->info; |
|
59 |
dst->next= dst + 1; |
|
60 |
}
|
|
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; |
|
67 |
}
|
|
68 |
}
|
|
69 |
elements= 0; |
|
70 |
first= &end_of_list; |
|
71 |
last= &first; |
|
72 |
}
|