~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/hash0hash.h

  • Committer: Monty Taylor
  • Date: 2008-09-15 17:24:04 UTC
  • Revision ID: monty@inaugust.com-20080915172404-ygh6hiyu0q7qpa9x
Removed strndup calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
/*****************************************************************
25
25
Creates a hash table with >= n array cells. The actual number
26
26
of cells is chosen to be a prime number slightly bigger than n. */
27
 
UNIV_INTERN
 
27
 
28
28
hash_table_t*
29
29
hash_create(
30
30
/*========*/
32
32
        ulint   n);     /* in: number of array cells */
33
33
/*****************************************************************
34
34
Creates a mutex array to protect a hash table. */
35
 
UNIV_INTERN
 
35
 
36
36
void
37
37
hash_create_mutexes_func(
38
38
/*=====================*/
50
50
 
51
51
/*****************************************************************
52
52
Frees a hash table. */
53
 
UNIV_INTERN
 
53
 
54
54
void
55
55
hash_table_free(
56
56
/*============*/
101
101
        }\
102
102
} while (0)
103
103
 
104
 
#ifdef UNIV_HASH_DEBUG
105
 
# define HASH_ASSERT_VALID(DATA) ut_a((void*) (DATA) != (void*) -1)
106
 
# define HASH_INVALIDATE(DATA, NAME) DATA->NAME = (void*) -1
107
 
#else
108
 
# define HASH_ASSERT_VALID(DATA) do {} while (0)
109
 
# define HASH_INVALIDATE(DATA, NAME) do {} while (0)
110
 
#endif
111
 
 
112
104
/***********************************************************************
113
105
Deletes a struct from a hash table. */
114
106
 
122
114
        cell3333 = hash_get_nth_cell(TABLE, hash_calc_hash(FOLD, TABLE));\
123
115
\
124
116
        if (cell3333->node == DATA) {\
125
 
                HASH_ASSERT_VALID(DATA->NAME);\
126
117
                cell3333->node = DATA->NAME;\
127
118
        } else {\
128
119
                struct3333 = cell3333->node;\
135
126
\
136
127
                struct3333->NAME = DATA->NAME;\
137
128
        }\
138
 
        HASH_INVALIDATE(DATA, NAME);\
139
129
} while (0)
140
130
 
141
131
/***********************************************************************
151
141
 
152
142
/************************************************************************
153
143
Looks for a struct in a hash table. */
154
 
#define HASH_SEARCH(NAME, TABLE, FOLD, TYPE, DATA, TEST)\
 
144
#define HASH_SEARCH(NAME, TABLE, FOLD, DATA, TEST)\
155
145
{\
156
146
\
157
147
        HASH_ASSERT_OWNED(TABLE, FOLD)\
158
148
\
159
 
        (DATA) = (TYPE) HASH_GET_FIRST(TABLE, hash_calc_hash(FOLD, TABLE));\
160
 
        HASH_ASSERT_VALID(DATA);\
 
149
        (DATA) = HASH_GET_FIRST(TABLE, hash_calc_hash(FOLD, TABLE));\
161
150
\
162
151
        while ((DATA) != NULL) {\
163
152
                if (TEST) {\
164
153
                        break;\
165
154
                } else {\
166
 
                        HASH_ASSERT_VALID(HASH_GET_NEXT(NAME, DATA));\
167
 
                        (DATA) = (TYPE) HASH_GET_NEXT(NAME, DATA);\
 
155
                        (DATA) = HASH_GET_NEXT(NAME, DATA);\
168
156
                }\
169
157
        }\
170
158
}
178
166
                                /* out: pointer to cell */
179
167
        hash_table_t*   table,  /* in: hash table */
180
168
        ulint           n);     /* in: cell index */
181
 
 
182
 
/*****************************************************************
183
 
Clears a hash table so that all the cells become empty. */
184
 
UNIV_INLINE
185
 
void
186
 
hash_table_clear(
187
 
/*=============*/
188
 
        hash_table_t*   table); /* in/out: hash table */
189
 
 
190
169
/*****************************************************************
191
170
Returns the number of cells in a hash table. */
192
171
UNIV_INLINE
327
306
        ulint           fold);  /* in: fold */
328
307
/****************************************************************
329
308
Reserves the mutex for a fold value in a hash table. */
330
 
UNIV_INTERN
 
309
 
331
310
void
332
311
hash_mutex_enter(
333
312
/*=============*/
335
314
        ulint           fold);  /* in: fold */
336
315
/****************************************************************
337
316
Releases the mutex for a fold value in a hash table. */
338
 
UNIV_INTERN
 
317
 
339
318
void
340
319
hash_mutex_exit(
341
320
/*============*/
343
322
        ulint           fold);  /* in: fold */
344
323
/****************************************************************
345
324
Reserves all the mutexes of a hash table, in an ascending order. */
346
 
UNIV_INTERN
 
325
 
347
326
void
348
327
hash_mutex_enter_all(
349
328
/*=================*/
350
329
        hash_table_t*   table); /* in: hash table */
351
330
/****************************************************************
352
331
Releases all the mutexes of a hash table. */
353
 
UNIV_INTERN
 
332
 
354
333
void
355
334
hash_mutex_exit_all(
356
335
/*================*/
363
342
 
364
343
/* The hash table structure */
365
344
struct hash_table_struct {
366
 
#ifdef UNIV_DEBUG
367
345
        ibool           adaptive;/* TRUE if this is the hash table of the
368
346
                                adaptive hash index */
369
 
#endif /* UNIV_DEBUG */
370
347
        ulint           n_cells;/* number of cells in the hash table */
371
348
        hash_cell_t*    array;  /* pointer to cell array */
372
349
        ulint           n_mutexes;/* if mutexes != NULL, then the number of