46 const uint key_offset, key_length;
47 const my_hash_get_key get_key;
50 my_hash_free_key free_element;
59 hash_filo(uint size, uint key_offset_arg , uint key_length_arg,
60 my_hash_get_key get_key_arg, my_hash_free_key free_element_arg,
62 : key_offset(key_offset_arg), key_length(key_length_arg),
63 get_key(get_key_arg), m_size(size),
64 free_element(free_element_arg),init(0),
65 hash_charset(hash_charset_arg),
69 memset(&cache, 0,
sizeof(cache));
76 if (cache.array.buffer)
77 (void) my_hash_free(&cache);
81 void clear(
bool locked=0)
92 (void) my_hash_free(&cache);
93 (void) my_hash_init(&cache, hash_charset, m_size, key_offset,
94 key_length, get_key, free_element,0);
116 my_hash_search(&cache,(uchar*) key,length);
119 DBUG_ASSERT(first_link != NULL);
120 DBUG_ASSERT(last_link != NULL);
121 if (entry != first_link)
123 if (entry == last_link)
125 last_link= last_link->prev_used;
130 DBUG_ASSERT(last_link != NULL);
131 last_link->next_used= NULL;
135 DBUG_ASSERT(entry->next_used != NULL);
136 DBUG_ASSERT(entry->prev_used != NULL);
137 entry->next_used->prev_used = entry->prev_used;
138 entry->prev_used->next_used = entry->next_used;
140 entry->prev_used= NULL;
141 entry->next_used= first_link;
143 first_link->prev_used=
entry;
152 if (!m_size)
return 1;
153 if (cache.records == m_size)
156 last_link= last_link->prev_used;
157 if (last_link != NULL)
159 last_link->next_used= NULL;
166 my_hash_delete(&cache,(uchar*) tmp);
168 if (my_hash_insert(&cache,(uchar*) entry))
171 (*free_element)(
entry);
174 entry->prev_used= NULL;
175 entry->next_used= first_link;
176 if (first_link != NULL)
177 first_link->prev_used=
entry;
188 void resize(uint new_size)