serializhe improved
This commit is contained in:
parent
c8595c3442
commit
7d2c48fb33
@ -28,21 +28,26 @@ ReturnValue_t SerialBufferAdapter<count_t>::serialize(uint8_t** buffer,
|
|||||||
serializedLength += SerializeAdapter::getSerializedSize(
|
serializedLength += SerializeAdapter::getSerializedSize(
|
||||||
&bufferLength);
|
&bufferLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*size + serializedLength > maxSize) {
|
if (*size + serializedLength > maxSize) {
|
||||||
return BUFFER_TOO_SHORT;
|
return BUFFER_TOO_SHORT;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if (serializeLength) {
|
if (serializeLength) {
|
||||||
SerializeAdapter::serialize(&bufferLength, buffer, size,
|
ReturnValue_t result = SerializeAdapter::serialize(&bufferLength,
|
||||||
maxSize, streamEndianness);
|
buffer, size, maxSize, streamEndianness);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this->constBuffer != nullptr) {
|
if (this->constBuffer != nullptr) {
|
||||||
memcpy(*buffer, this->constBuffer, bufferLength);
|
std::memcpy(*buffer, this->constBuffer, bufferLength);
|
||||||
}
|
}
|
||||||
else if (this->buffer != nullptr) {
|
else if (this->buffer != nullptr) {
|
||||||
// This will propably be never reached, constBuffer should always be
|
// This will propably be never reached, constBuffer should always be
|
||||||
// set if non-const buffer is set.
|
// set if non-const buffer is set.
|
||||||
memcpy(*buffer, this->buffer, bufferLength);
|
std::memcpy(*buffer, this->buffer, bufferLength);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
@ -50,7 +55,7 @@ ReturnValue_t SerialBufferAdapter<count_t>::serialize(uint8_t** buffer,
|
|||||||
*size += bufferLength;
|
*size += bufferLength;
|
||||||
(*buffer) += bufferLength;
|
(*buffer) += bufferLength;
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename count_t>
|
template<typename count_t>
|
||||||
|
Loading…
Reference in New Issue
Block a user