Make raw senders able to send flatbuffers
The senders were placing in the front of the memory region, and the
readers were reading from the end of the memory region. Align the
raw senders with how flatbuffers use the memory.
This was found by trying to implement message_gateway.
Change-Id: I2d8fd5b6faafbbaf268ee036c851417cf5a02c74
diff --git a/aos/ipc_lib/lockless_queue.cc b/aos/ipc_lib/lockless_queue.cc
index a4539f8..0c87e4d 100644
--- a/aos/ipc_lib/lockless_queue.cc
+++ b/aos/ipc_lib/lockless_queue.cc
@@ -549,7 +549,10 @@
void LocklessQueue::Sender::Send(const char *data, size_t length) {
CHECK_LE(length, size());
- memcpy(Data(), data, length);
+ // Flatbuffers write from the back of the buffer to the front. If we are
+ // going to write an explicit chunk of memory into the buffer, we need to
+ // adhere to this convention and place it at the end.
+ memcpy((reinterpret_cast<char *>(Data()) + size() - length), data, length);
Send(length);
}