seriasl buffer update
This commit is contained in:
parent
b97128c12e
commit
92e18b91a3
@ -23,26 +23,25 @@ SerialBufferAdapter<count_t>::~SerialBufferAdapter() {
|
|||||||
template<typename count_t>
|
template<typename count_t>
|
||||||
ReturnValue_t SerialBufferAdapter<count_t>::serialize(uint8_t** buffer,
|
ReturnValue_t SerialBufferAdapter<count_t>::serialize(uint8_t** buffer,
|
||||||
size_t* size, size_t maxSize, Endianness streamEndianness) const {
|
size_t* size, size_t maxSize, Endianness streamEndianness) const {
|
||||||
uint32_t serializedLength = bufferLength;
|
|
||||||
if (serializeLength) {
|
if (serializeLength) {
|
||||||
serializedLength += SerializeAdapter::getSerializedSize(
|
ReturnValue_t result = SerializeAdapter::serialize(&bufferLength,
|
||||||
&bufferLength);
|
buffer, size, maxSize, streamEndianness);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
if (*size + serializedLength > maxSize) {
|
}
|
||||||
|
|
||||||
|
if (*size + bufferLength > maxSize) {
|
||||||
return BUFFER_TOO_SHORT;
|
return BUFFER_TOO_SHORT;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if (serializeLength) {
|
|
||||||
SerializeAdapter::serialize(&bufferLength, buffer, size,
|
|
||||||
maxSize, streamEndianness);
|
|
||||||
}
|
|
||||||
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 +49,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>
|
||||||
@ -126,4 +125,6 @@ void SerialBufferAdapter<count_t>::setBuffer(uint8_t* buffer,
|
|||||||
template class SerialBufferAdapter<uint8_t>;
|
template class SerialBufferAdapter<uint8_t>;
|
||||||
template class SerialBufferAdapter<uint16_t>;
|
template class SerialBufferAdapter<uint16_t>;
|
||||||
template class SerialBufferAdapter<uint32_t>;
|
template class SerialBufferAdapter<uint32_t>;
|
||||||
|
template class SerialBufferAdapter<uint64_t>;
|
||||||
|
template class SerialBufferAdapter<size_t>;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user