~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/ha/hash0hash.c

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
/****************************************************************
17
17
Reserves the mutex for a fold value in a hash table. */
18
 
UNIV_INTERN
 
18
 
19
19
void
20
20
hash_mutex_enter(
21
21
/*=============*/
27
27
 
28
28
/****************************************************************
29
29
Releases the mutex for a fold value in a hash table. */
30
 
UNIV_INTERN
 
30
 
31
31
void
32
32
hash_mutex_exit(
33
33
/*============*/
39
39
 
40
40
/****************************************************************
41
41
Reserves all the mutexes of a hash table, in an ascending order. */
42
 
UNIV_INTERN
 
42
 
43
43
void
44
44
hash_mutex_enter_all(
45
45
/*=================*/
55
55
 
56
56
/****************************************************************
57
57
Releases all the mutexes of a hash table. */
58
 
UNIV_INTERN
 
58
 
59
59
void
60
60
hash_mutex_exit_all(
61
61
/*================*/
72
72
/*****************************************************************
73
73
Creates a hash table with >= n array cells. The actual number of cells is
74
74
chosen to be a prime number slightly bigger than n. */
75
 
UNIV_INTERN
 
75
 
76
76
hash_table_t*
77
77
hash_create(
78
78
/*========*/
82
82
        hash_cell_t*    array;
83
83
        ulint           prime;
84
84
        hash_table_t*   table;
 
85
        ulint           i;
 
86
        hash_cell_t*    cell;
85
87
 
86
88
        prime = ut_find_prime(n);
87
89
 
89
91
 
90
92
        array = ut_malloc(sizeof(hash_cell_t) * prime);
91
93
 
92
 
#ifdef UNIV_DEBUG
93
94
        table->adaptive = FALSE;
94
 
#endif /* UNIV_DEBUG */
95
95
        table->array = array;
96
96
        table->n_cells = prime;
97
97
        table->n_mutexes = 0;
101
101
        table->magic_n = HASH_TABLE_MAGIC_N;
102
102
 
103
103
        /* Initialize the cell array */
104
 
        hash_table_clear(table);
 
104
 
 
105
        for (i = 0; i < prime; i++) {
 
106
 
 
107
                cell = hash_get_nth_cell(table, i);
 
108
                cell->node = NULL;
 
109
        }
105
110
 
106
111
        return(table);
107
112
}
108
113
 
109
114
/*****************************************************************
110
115
Frees a hash table. */
111
 
UNIV_INTERN
 
116
 
112
117
void
113
118
hash_table_free(
114
119
/*============*/
122
127
 
123
128
/*****************************************************************
124
129
Creates a mutex array to protect a hash table. */
125
 
UNIV_INTERN
 
130
 
126
131
void
127
132
hash_create_mutexes_func(
128
133
/*=====================*/
136
141
{
137
142
        ulint   i;
138
143
 
139
 
        ut_a(n_mutexes > 0);
140
 
        ut_a(ut_is_2pow(n_mutexes));
 
144
        ut_a(n_mutexes == ut_2_power_up(n_mutexes));
141
145
 
142
146
        table->mutexes = mem_alloc(n_mutexes * sizeof(mutex_t));
143
147