MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / UpdateLink

Method UpdateLink

lib/mdflib/mdflib/src/mdfblock.cpp:723–747  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

721
722
723void MdfBlock::UpdateLink(std::streambuf& buffer, size_t link_index, int64_t link) {
724 if (link_index >= link_list_.size()) {
725 throw std::runtime_error("index is out of bounds");
726 }
727 if (link == link_list_[link_index]) {
728 return; // No need to update the link
729 }
730
731 auto pos = FilePosition();
732
733 // If the block not yet is written, the link will be written later
734 if (pos > 0) {
735 if (IsMdf4()) {
736 pos += 24 + static_cast<int64_t>(link_index * 8);
737 SetFilePosition(buffer, pos);
738 WriteNumber(buffer, link);
739 } else {
740 pos += 4 + static_cast<int64_t>(link_index * 4);
741 const auto link32 = static_cast<uint32_t>(link);
742 SetFilePosition(buffer, pos);
743 WriteNumber(buffer, link32);
744 }
745 }
746 link_list_[link_index] = link;
747}
748
749void MdfBlock::UpdateBlockSize(std::streambuf& buffer, uint64_t bytes) {
750 auto pos = FilePosition();

Callers 6

WriteMethod · 0.80
WriteMethod · 0.80
SetLastPositionMethod · 0.80
SetLastPositionMethod · 0.80
WriteLink4ListMethod · 0.80
WriteMethod · 0.80

Calls 2

SetFilePositionFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected