MySQL 5.6.14 Source Code Document
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
innodb_utility.h
1
/***********************************************************************
2
3
Copyright (c) 2012, Oracle and/or its affiliates. All Rights Reserved.
4
5
This program is free software; you can redistribute it and/or modify it
6
under the terms of the GNU General Public License as published by the
7
Free Software Foundation; version 2 of the License.
8
9
This program is distributed in the hope that it will be useful, but
10
WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
12
Public License for more details.
13
14
You should have received a copy of the GNU General Public License along
15
with this program; if not, write to the Free Software Foundation, Inc.,
16
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
17
18
***********************************************************************/
19
/**************************************************/
27
#ifndef INNODB_UTILITY_H
28
#define INNODB_UTILITY_H
29
30
#include "config.h"
31
#include "
api0api.h
"
32
33
34
#define UT_LIST_NODE_T(TYPE) \
35
struct { \
36
TYPE* prev; \
38
TYPE* next; \
39
} \
40
41
#define UT_LIST_BASE_NODE_T(TYPE) \
42
struct { \
43
int count; \
44
TYPE * start; \
45
TYPE * end; \
46
}
47
49
#define UT_LIST_INIT(BASE) \
50
{ \
51
(BASE).count = 0; \
52
(BASE).start = NULL; \
53
(BASE).end = NULL; \
54
} \
55
56
#define UT_LIST_ADD_LAST(NAME, BASE, N) \
57
{ \
58
((BASE).count)++; \
59
((N)->NAME).prev = (BASE).end; \
60
((N)->NAME).next = NULL; \
61
if ((BASE).end != NULL) { \
62
(((BASE).end)->NAME).next = (N); \
63
} \
64
(BASE).end = (N); \
65
if ((BASE).start == NULL) { \
66
(BASE).start = (N); \
67
} \
68
} \
69
70
#define UT_LIST_ADD_FIRST(NAME, BASE, N) \
71
{ \
72
((BASE).count)++; \
73
((N)->NAME).next = (BASE).start; \
74
((N)->NAME).prev = NULL; \
75
if (UNIV_LIKELY((BASE).start != NULL)) { \
76
(((BASE).start)->NAME).prev = (N); \
77
} \
78
(BASE).start = (N); \
79
if (UNIV_UNLIKELY((BASE).end == NULL)) { \
80
(BASE).end = (N); \
81
} \
82
} \
83
84
# define UT_LIST_REMOVE_CLEAR(NAME, N) \
85
((N)->NAME.prev = (N)->NAME.next = (void*) -1)
86
88
#define UT_LIST_REMOVE(NAME, BASE, N) \
89
do { \
90
((BASE).count)--; \
91
if (((N)->NAME).next != NULL) { \
92
((((N)->NAME).next)->NAME).prev = ((N)->NAME).prev; \
93
} else { \
94
(BASE).end = ((N)->NAME).prev; \
95
} \
96
if (((N)->NAME).prev != NULL) { \
97
((((N)->NAME).prev)->NAME).next = ((N)->NAME).next; \
98
} else { \
99
(BASE).start = ((N)->NAME).next; \
100
} \
101
UT_LIST_REMOVE_CLEAR(NAME, N); \
102
} while (0)
103
104
#define UT_LIST_GET_NEXT(NAME, N) (((N)->NAME).next)
105
106
#define UT_LIST_GET_LEN(BASE) (BASE).count
107
108
#define UT_LIST_GET_FIRST(BASE) (BASE).start
109
110
/*************************************************************/
115
ib_ulint_t
116
ut_fold_string(
117
/*===========*/
118
const
char
* str);
120
typedef
struct
hash_cell_struct
{
121
void
*
node
;
122
}
hash_cell_t
;
123
124
typedef
struct
hash_table_struct
{
125
ib_ulint_t
n_cells;
/* number of cells in the hash table */
126
hash_cell_t
*
array
;
127
}
hash_table_t
;
128
129
#define HASH_INSERT(TYPE, NAME, TABLE, FOLD, DATA) \
130
do { \
131
hash_cell_t* cell3333; \
132
TYPE* struct3333; \
133
\
134
\
135
(DATA)->NAME = NULL; \
136
\
137
cell3333 = hash_get_nth_cell(TABLE, hash_calc_hash(FOLD, TABLE));\
138
\
139
if (cell3333->node == NULL) { \
140
cell3333->node = DATA; \
141
} else { \
142
struct3333 = (TYPE*) cell3333->node; \
143
\
144
while (struct3333->NAME != NULL) { \
145
\
146
struct3333 = (TYPE*) struct3333->NAME;\
147
} \
148
\
149
struct3333->NAME = DATA; \
150
} \
151
} while (0)
152
153
/*******************************************************************/
156
#define HASH_GET_FIRST(TABLE, HASH_VAL) \
157
(hash_get_nth_cell(TABLE, HASH_VAL)->node)
158
159
/*******************************************************************/
162
#define HASH_GET_NEXT(NAME, DATA) ((DATA)->NAME)
163
164
/********************************************************************/
166
#define HASH_SEARCH(NAME, TABLE, FOLD, TYPE, DATA, TEST) \
167
{ \
168
(DATA) = (TYPE) HASH_GET_FIRST(TABLE, hash_calc_hash(FOLD, TABLE));\
169
\
170
while ((DATA) != NULL) { \
171
if (TEST) { \
172
break; \
173
} else { \
174
(DATA) = (TYPE) HASH_GET_NEXT(NAME, DATA); \
175
} \
176
} \
177
}
178
179
180
/********************************************************************/
182
#define HASH_CLEANUP(TABLE, TYPE) \
183
do { \
184
ib_ulint_t i; \
185
TYPE data; \
186
\
187
for (i = 0; i < TABLE->n_cells; i++) { \
188
data = (TYPE) HASH_GET_FIRST(TABLE, i); \
189
\
190
while (data) { \
191
TYPE next_data; \
192
next_data = HASH_GET_NEXT(name_hash, data); \
193
innodb_config_free(data); \
194
free(data); \
195
data = next_data; \
196
} \
197
} \
198
\
199
free(TABLE->array); \
200
free(TABLE); \
201
} while(0)
202
203
/************************************************************/
206
hash_cell_t
*
207
hash_get_nth_cell
(
208
/*==============*/
209
hash_table_t
*
table
,
210
ib_ulint_t
n
);
212
/*************************************************************/
216
hash_table_t
*
217
hash_create(
218
/*========*/
219
ib_ulint_t
n
);
221
/**************************************************************/
224
ib_ulint_t
225
hash_calc_hash
(
226
/*===========*/
227
ib_ulint_t
fold
,
228
hash_table_t
*
table
);
230
#endif
/* INNODB_UTILITY_H */
plugin
innodb_memcached
innodb_memcache
include
innodb_utility.h
Generated on Sat Nov 9 2013 01:25:13 for MySQL 5.6.14 Source Code Document by
1.8.1.2