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 DRIZZLED_SQL_LIST_H
21
#define DRIZZLED_SQL_LIST_H
27
#include <drizzled/sql_alloc.h>
29
/** Struct to handle simple linked lists. */
30
typedef struct st_sql_list {
35
st_sql_list() {} /* Remove gcc warning */
42
inline void link_in_list(unsigned char *element,unsigned char **next_ptr)
49
inline void save_and_clear(struct st_sql_list *save)
54
inline void push_front(struct st_sql_list *save)
56
*save->next= first; /* link current list last */
58
elements+= save->elements;
60
inline void push_back(struct st_sql_list *save)
66
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 */
23
/* mysql standard class memory allocator */
28
static void *operator new(size_t size) throw ()
30
return sql_alloc(size);
32
static void *operator new[](size_t size)
34
return sql_alloc(size);
36
static void *operator new[](size_t size, MEM_ROOT *mem_root) throw ()
37
{ return alloc_root(mem_root, size); }
38
static void *operator new(size_t size, MEM_ROOT *mem_root) throw ()
39
{ return alloc_root(mem_root, size); }
40
static void operator delete(void *ptr __attribute__((__unused__)),
41
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__)))
54
inline Sql_alloc() :dummy(0) {}
55
inline ~Sql_alloc() {}
58
inline ~Sql_alloc() {}
72
65
Basic single linked list
225
218
inline void swap(base_list &rhs)
227
std::swap(first, rhs.first);
228
std::swap(last, rhs.last);
229
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);
231
224
inline list_node* last_node() { return *last; }
232
225
inline list_node* first_node() { return first;}
460
453
struct ilink **prev,*next;
461
454
static void *operator new(size_t size)
463
return (void*)malloc((uint32_t)size);
456
return (void*)my_malloc((uint)size, MYF(MY_WME | MY_FAE | ME_FATALERROR));
465
static void operator delete(void* ptr_arg, size_t)
458
static void operator delete(void* ptr_arg,
459
size_t size __attribute__((__unused__)))
467
free((unsigned char*)ptr_arg);
461
my_free((uchar*)ptr_arg, MYF(MY_WME|MY_ALLOW_ZERO_PTR));