1
0
mirror of https://github.com/apple/foundationdb.git synced 2025-05-25 17:00:05 +08:00

Allow zero length strings

This commit is contained in:
Lukas Joswiak 2021-01-13 16:16:40 -08:00
parent 7ae5e98c5a
commit 5f5f487967

@ -209,13 +209,13 @@ private:
// Writes the given string to the request as a sequence of bytes. Inserts a // Writes the given string to the request as a sequence of bytes. Inserts a
// format byte at the beginning of the string according to the its length, // format byte at the beginning of the string according to the its length,
// as specified by the msgpack specification. String length must be greater // as specified by the msgpack specification.
// than 0.
inline void serialize_string(const std::string& str, TraceRequest& request) { inline void serialize_string(const std::string& str, TraceRequest& request) {
int size = str.size(); int size = str.size();
ASSERT(size > 0);
if (size <= 31) { if (size <= 31) {
// A size 0 string is ok. We still need to write a byte
// identifiying the item as a string, but can set the size to 0.
request.write_byte(static_cast<uint8_t>(size) | 0b10100000); request.write_byte(static_cast<uint8_t>(size) | 0b10100000);
} else if (size <= 255) { } else if (size <= 255) {
request.write_byte(0xd9); request.write_byte(0xd9);