| 497 | } |
| 498 | |
| 499 | bool |
| 500 | XpackDynamicTable::_make_space(uint64_t extra_space_needed) |
| 501 | { |
| 502 | uint32_t freed = 0; |
| 503 | uint32_t tail = this->_entries_tail; |
| 504 | |
| 505 | // Check to see if we need more space and that we have entries to evict |
| 506 | while (extra_space_needed > freed && this->_entries_head != tail) { |
| 507 | tail = this->_calc_index(tail, 1); // Move to the next entry |
| 508 | |
| 509 | if (this->_entries[tail].ref_count) { |
| 510 | break; |
| 511 | } |
| 512 | freed += this->_entries[tail].name_len + this->_entries[tail].value_len + ADDITIONAL_32_BYTES; |
| 513 | } |
| 514 | |
| 515 | // Evict |
| 516 | if (freed > 0) { |
| 517 | XPACKDbg("Evict entries: from %u to %u", this->_entries[this->_calc_index(this->_entries_tail, 1)].index, |
| 518 | this->_entries[tail - 1].index); |
| 519 | this->_available += freed; |
| 520 | this->_entries_tail = tail; |
| 521 | |
| 522 | XPACKDbg("Available size: %u", this->_available); |
| 523 | } |
| 524 | |
| 525 | return freed >= extra_space_needed; |
| 526 | } |
| 527 | |
| 528 | uint32_t |
| 529 | XpackDynamicTable::_calc_index(uint32_t base, int64_t offset) const |
no test coverage detected