Make Flattenable not virtual
Fallout from the Flattenable change, update all its uses.
Additionnaly, fix/tighten size checks when (un)flatten()ing
things.
Removed the assumption by some flattenables (e.g.: Fence)
that the size passed to them would be exact (it can
and will be larger in some cases)
The code in Parcel is a bit complicated so that we don't
have to expose the full implementation (and also to
keep the code smallish).
Change-Id: I0bf1c8aca2a3128491b4f45510bc46667e566dde
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 359742c..7a5919f 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -798,13 +798,13 @@
return status;
}
-status_t Parcel::write(const Flattenable& val)
+status_t Parcel::write(const FlattenableHelperInterface& val)
{
status_t err;
// size if needed
- size_t len = val.getFlattenedSize();
- size_t fd_count = val.getFdCount();
+ const size_t len = val.getFlattenedSize();
+ const size_t fd_count = val.getFdCount();
err = this->writeInt32(len);
if (err) return err;
@@ -813,7 +813,7 @@
if (err) return err;
// payload
- void* buf = this->writeInplace(PAD_SIZE(len));
+ void* const buf = this->writeInplace(PAD_SIZE(len));
if (buf == NULL)
return BAD_VALUE;
@@ -1174,14 +1174,14 @@
return NO_ERROR;
}
-status_t Parcel::read(Flattenable& val) const
+status_t Parcel::read(FlattenableHelperInterface& val) const
{
// size
const size_t len = this->readInt32();
const size_t fd_count = this->readInt32();
// payload
- void const* buf = this->readInplace(PAD_SIZE(len));
+ void const* const buf = this->readInplace(PAD_SIZE(len));
if (buf == NULL)
return BAD_VALUE;