This returns a segment that does not share ownership of the original memory, so when the original is deleted, this is destroyed also, and without warning. Very easy to insert bugs in your code, which is why it is called segmentTemp to indicate that it is a ByteVector for temporary use only.
| 140 | // Very easy to insert bugs in your code, which is why it is called segmentTemp to indicate |
| 141 | // that it is a ByteVector for temporary use only. |
| 142 | const ByteVectorTemp ByteVector::segmentTemp(size_t start, size_t span) const |
| 143 | { |
| 144 | BVASSERT(start+span <= size()); |
| 145 | ByteType* wStart = mStart + start; |
| 146 | ByteType* wEnd = wStart + span; |
| 147 | //BVASSERT(wEnd<=mEnd); |
| 148 | return ByteVectorTemp(wStart,wEnd); |
| 149 | } |
| 150 | |
| 151 | // Copy other to this starting at start. |
| 152 | // The 'this' ByteVector must be allocated large enough to hold other. |
no test coverage detected