MessageBuffer: add CanFitEver()
The CanFitEver() method will be used to determine
whether the MessageBuffer can host an incoming
message, or if the incoming message requires
compression.
Bug: 31653003
Test: ./runtests.sh (on bullhead)
Change-Id: If09ae5bc6c7c80a71e490e945187bd6fc25529b1
diff --git a/message_buffer.cpp b/message_buffer.cpp
index 49902bf..12b41be 100644
--- a/message_buffer.cpp
+++ b/message_buffer.cpp
@@ -41,6 +41,11 @@
return true;
}
+bool MessageBuffer::CanFitEver(uint16_t length) const {
+ // This unusual formulation is intended to avoid overflow.
+ return capacity_ - GetHeaderSize() >= length;
+}
+
bool MessageBuffer::CanFitNow(uint16_t length) const {
// This unusual formulation is intended to avoid overflow/underflow.
return GetFreeSize() >= GetHeaderSize() &&