1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef INCLUDES_DRIZZLE_SQL_LIST_H
21
#define INCLUDES_DRIZZLE_SQL_LIST_H
27
/** Struct to handle simple linked lists. */
28
typedef struct st_sql_list {
33
st_sql_list() {} /* Remove gcc warning */
40
inline void link_in_list(unsigned char *element,unsigned char **next_ptr)
47
inline void save_and_clear(struct st_sql_list *save)
52
inline void push_front(struct st_sql_list *save)
54
*save->next= first; /* link current list last */
56
elements+= save->elements;
58
inline void push_back(struct st_sql_list *save)
64
elements+= save->elements;
1
#ifndef INCLUDES_MYSQL_SQL_LIST_H
2
#define INCLUDES_MYSQL_SQL_LIST_H
3
/* Copyright (C) 2000-2003 MySQL AB
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
19
#ifdef USE_PRAGMA_INTERFACE
20
#pragma interface /* gcc class implementation */
69
23
/* mysql standard class memory allocator */
82
37
{ return alloc_root(mem_root, size); }
83
38
static void *operator new(size_t size, MEM_ROOT *mem_root) throw ()
84
39
{ return alloc_root(mem_root, size); }
85
static void operator delete(void *ptr __attribute__((unused)),
86
size_t size __attribute__((unused)))
40
static void operator delete(void *ptr __attribute__((__unused__)),
41
size_t size __attribute__((__unused__)))
87
42
{ TRASH(ptr, size); }
88
static void operator delete(void *ptr __attribute__((unused)),
89
MEM_ROOT *mem_root __attribute__((unused)))
90
{ /* never called */ }
91
static void operator delete[](void *ptr __attribute__((unused)),
92
MEM_ROOT *mem_root __attribute__((unused)))
93
{ /* never called */ }
94
static void operator delete[](void *ptr __attribute__((unused)),
95
size_t size __attribute__((unused)))
43
static void operator delete(void *ptr __attribute__((__unused__)),
44
MEM_ROOT *mem_root __attribute__((__unused__)))
45
{ /* never called */ }
46
static void operator delete[](void *ptr __attribute__((__unused__)),
47
MEM_ROOT *mem_root __attribute__((__unused__)))
48
{ /* never called */ }
49
static void operator delete[](void *ptr __attribute__((__unused__)),
50
size_t size __attribute__((__unused__)))
96
51
{ TRASH(ptr, size); }
171
126
list_copy_and_replace_each_value after creating a copy.
173
128
base_list(const base_list &rhs, MEM_ROOT *mem_root);
174
inline base_list(bool error __attribute__((unused))) { }
129
inline base_list(bool error __attribute__((__unused__))) { }
175
130
inline bool push_back(void *info)
177
132
if (((*last)=new list_node(info, &end_of_list)))
263
218
inline void swap(base_list &rhs)
265
std::swap(first, rhs.first);
266
std::swap(last, rhs.last);
267
std::swap(elements, rhs.elements);
220
swap_variables(list_node *, first, rhs.first);
221
swap_variables(list_node **, last, rhs.last);
222
swap_variables(uint, elements, rhs.elements);
269
224
inline list_node* last_node() { return *last; }
270
225
inline list_node* first_node() { return first;}
297
252
base_list *list= this;
298
253
list_node *node= first;
301
256
while (node->next != &end_of_list)
260
DBUG_PRINT("list_invariants",("%s: error: NULL element in the list",
307
264
node= node->next;
310
267
if (last != &(node->next))
269
DBUG_PRINT("list_invariants", ("%s: error: wrong last pointer", name));
314
272
if (cnt+1 != elements)
274
DBUG_PRINT("list_invariants", ("%s: error: wrong element count", name));
277
DBUG_PRINT("list_invariants", ("%s: list is ok", name));
320
280
#endif // LIST_EXTRA_DEBUG
469
429
template <class T> class List_iterator_fast :public base_list_iterator
472
inline T *replace(T *a __attribute__((unused))) { return (T*) 0; }
473
inline T *replace(List<T> &a __attribute__((unused))) { return (T*) 0; }
432
inline T *replace(T *a __attribute__((__unused__))) { return (T*) 0; }
433
inline T *replace(List<T> &a __attribute__((__unused__))) { return (T*) 0; }
474
434
inline void remove(void) { }
475
inline void after(T *a __attribute__((unused))) { }
435
inline void after(T *a __attribute__((__unused__))) { }
476
436
inline T** ref(void) { return (T**) 0; }
481
441
inline void init(List<T> &a) { base_list_iterator::init(a); }
482
442
inline T* operator++(int) { return (T*) base_list_iterator::next_fast(); }
483
443
inline void rewind(void) { base_list_iterator::rewind(); }
484
void sublist(List<T> &list_arg, uint32_t el_arg)
444
void sublist(List<T> &list_arg, uint el_arg)
486
446
base_list_iterator::sublist(list_arg, el_arg);
501
461
return (void*)my_malloc((uint)size, MYF(MY_WME | MY_FAE | ME_FATALERROR));
503
463
static void operator delete(void* ptr_arg,
504
size_t size __attribute__((unused)))
464
size_t size __attribute__((__unused__)))
506
free((unsigned char*)ptr_arg);
466
my_free((uchar*)ptr_arg, MYF(MY_WME|MY_ALLOW_ZERO_PTR));