diff options
| author | 2011-04-13 18:15:56 -0700 | |
|---|---|---|
| committer | 2011-04-14 10:57:22 -0700 | |
| commit | 97e2bcd76021b31c5064fd3f669bc3f450b4c952 (patch) | |
| tree | c5bf653c619146e8824a565465cc54c0cf7d401e /libs/binder/Parcel.cpp | |
| parent | 4849bc5b3d26909307841270082283930f4dc1df (diff) | |
Rewrite battery history storage.
We now write battery history directly into a buffer, instead of
creating objects. This allows for more efficient storage; later
it can be even better because we can only write deltas.
The old code is still there temporarily for validation.
Change-Id: I9707d4d8ff30855be8ebdc93bc078911040d8e0b
Diffstat (limited to 'libs/binder/Parcel.cpp')
| -rw-r--r-- | libs/binder/Parcel.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index d57f2c9fdc..6ed85d722f 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -338,7 +338,7 @@ void Parcel::setDataPosition(size_t pos) const status_t Parcel::setDataCapacity(size_t size) { - if (size > mDataSize) return continueWrite(size); + if (size > mDataCapacity) return continueWrite(size); return NO_ERROR; } @@ -386,10 +386,12 @@ status_t Parcel::appendFrom(Parcel *parcel, size_t offset, size_t len) } int numObjects = lastIndex - firstIndex + 1; - // grow data - err = growData(len); - if (err != NO_ERROR) { - return err; + if ((mDataSize+len) > mDataCapacity) { + // grow data + err = growData(len); + if (err != NO_ERROR) { + return err; + } } // append data @@ -1384,8 +1386,10 @@ status_t Parcel::continueWrite(size_t desired) return NO_MEMORY; } } else { - mDataSize = desired; - LOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize); + if (mDataSize > desired) { + mDataSize = desired; + LOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize); + } if (mDataPos > desired) { mDataPos = desired; LOGV("continueWrite Setting data pos of %p to %d\n", this, mDataPos); |