I defined a simple bytes message below
message MfStream {
bytes message=1;
}
and run a test below, in which I use for a loop to keep
serialize/deserialize the bytes message.
char buf[1024];
int tmp = 1;
MfStream testMsg;
testMsg.set_message(&tmp, sizeof(tmp));
for (int i=0; i<5; i++) {
int size = testMsg.ByteSize();
testMsg.SerializeToArray(buf, sizeof(buf));
cout << "i=" << i << ", size=" << size << endl;
testMsg.set_message(buf, size);
}
The results below shows that the message size keeps increasing by 2 every
loop. Why? How should I serialize/deserialize bytes data?
i=0, size=6
i=1, size=8
i=2, size=10
i=3, size=12
i=4, size=14
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.