| 5303 | /// class BCBHashTable |
| 5304 | |
| 5305 | void BCBHashTable::resize(ULONG count) |
| 5306 | { |
| 5307 | const ULONG old_count = m_count; |
| 5308 | chain_type* const old_chains = m_chains; |
| 5309 | |
| 5310 | chain_type* new_chains = FB_NEW_POOL(m_pool) chain_type[count]; |
| 5311 | m_count = count; |
| 5312 | m_chains = new_chains; |
| 5313 | |
| 5314 | #ifndef HASH_USE_CDS_LIST |
| 5315 | // Initialize all new new_chains |
| 5316 | for (chain_type* que = new_chains; que < new_chains + count; que++) |
| 5317 | QUE_INIT(*que); |
| 5318 | #endif |
| 5319 | |
| 5320 | if (!old_chains) |
| 5321 | return; |
| 5322 | |
| 5323 | const chain_type* const old_end = old_chains + old_count; |
| 5324 | |
| 5325 | // Move any active buffers from old hash table to new |
| 5326 | for (chain_type* old_tail = old_chains; old_tail < old_end; old_tail++) |
| 5327 | { |
| 5328 | #ifndef HASH_USE_CDS_LIST |
| 5329 | while (QUE_NOT_EMPTY(*old_tail)) |
| 5330 | { |
| 5331 | QUE que_inst = old_tail->que_forward; |
| 5332 | BufferDesc* bdb = BLOCK(que_inst, BufferDesc, bdb_que); |
| 5333 | QUE_DELETE(*que_inst); |
| 5334 | QUE mod_que = &new_chains[hash(bdb->bdb_page)]; |
| 5335 | QUE_INSERT(*mod_que, *que_inst); |
| 5336 | } |
| 5337 | #else |
| 5338 | while (!old_tail->empty()) |
| 5339 | { |
| 5340 | auto n = old_tail->begin(); |
| 5341 | old_tail->erase(n->first); // bdb_page |
| 5342 | |
| 5343 | chain_type* new_chain = &m_chains[hash(n->first)]; |
| 5344 | new_chain->insert(n->first, n->second); // bdb_page, bdb |
| 5345 | } |
| 5346 | #endif |
| 5347 | } |
| 5348 | |
| 5349 | delete[] old_chains; |
| 5350 | } |
| 5351 | |
| 5352 | void BCBHashTable::clear() |
| 5353 | { |
no test coverage detected