| 560 | } |
| 561 | |
| 562 | uint32_t |
| 563 | XpackDynamicTableStorage::write(const char *name, uint32_t name_len, const char *value, uint32_t value_len) |
| 564 | { |
| 565 | // insert_entry should guard against buffer overrun, but rather than overrun |
| 566 | // our buffer we assert here in case something horrible went wrong. |
| 567 | ink_release_assert(name_len + value_len <= this->_capacity); |
| 568 | ink_release_assert(this->_head == this->_capacity - 1 || this->_head + name_len + value_len <= this->_capacity); |
| 569 | |
| 570 | uint32_t offset = (this->_head + 1) % this->_capacity; |
| 571 | if (name_len > 0) { |
| 572 | memcpy(this->_data + offset, name, name_len); |
| 573 | } |
| 574 | if (value_len > 0) { |
| 575 | memcpy(this->_data + offset + name_len, value, value_len); |
| 576 | } |
| 577 | |
| 578 | this->_head = (this->_head + (name_len + value_len)) % this->_capacity; |
| 579 | if (this->_head > this->_overwrite_threshold) { |
| 580 | // This is how we wrap back around to the beginning of the buffer. |
| 581 | this->_head = this->_capacity - 1; |
| 582 | } |
| 583 | |
| 584 | return offset; |
| 585 | } |
| 586 | |
| 587 | bool |
| 588 | XpackDynamicTableStorage::_start_expanding_capacity(uint32_t new_maximum_size) |