logging of live data structs was: data points #3614
support for null fragments
This commit is contained in:
parent
0b1dedcbdb
commit
cd080b159f
|
@ -24,7 +24,12 @@ void copyRange(uint8_t *destination, FragmentEntry *fragments, size_t dataOffset
|
|||
|
||||
while (dataLength > 0) {
|
||||
int copyNowSize = minI(dataLength, fragments[fragmentIndex].size - dataOffset);
|
||||
memcpy(destination + destinationIndex, fragments[fragmentIndex].data + dataOffset, copyNowSize);
|
||||
const uint8_t *fromBase = fragments[fragmentIndex].data;
|
||||
if (fromBase == nullptr) {
|
||||
memset(destination + destinationIndex, 0, copyNowSize);
|
||||
} else {
|
||||
memcpy(destination + destinationIndex, fromBase + dataOffset, copyNowSize);
|
||||
}
|
||||
destinationIndex += copyNowSize;
|
||||
dataOffset = 0;
|
||||
dataLength -= copyNowSize;
|
||||
|
|
|
@ -7,6 +7,7 @@ static uint8_t buffer5[] = {11, 12, 13, 14, 15};
|
|||
static FragmentEntry fragments[] = {
|
||||
FragmentEntry(buffer10, sizeof(buffer10)),
|
||||
FragmentEntry(buffer5, sizeof(buffer5)),
|
||||
FragmentEntry(nullptr, sizeof(5)),
|
||||
};
|
||||
|
||||
TEST(outputs, fragments) {
|
||||
|
@ -22,4 +23,10 @@ TEST(outputs, fragments) {
|
|||
copyRange(buffer, fragments, 12, 3);
|
||||
EXPECT_TRUE( 0 == std::memcmp(buffer, expected, sizeof(expected)));
|
||||
}
|
||||
|
||||
{
|
||||
uint8_t expected[] = {15, 0, 0};
|
||||
copyRange(buffer, fragments, 14, 3);
|
||||
EXPECT_TRUE( 0 == std::memcmp(buffer, expected, sizeof(expected)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue