Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Unified Diff: base/pickle.cc

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/pickle.h ('k') | base/port.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/pickle.cc
diff --git a/base/pickle.cc b/base/pickle.cc
index 09d42c9deb0165b12e46d46b798e57b45f4f041a..cf4a865d35c337421b0acea57a05211fa076b06f 100644
--- a/base/pickle.cc
+++ b/base/pickle.cc
@@ -317,13 +317,17 @@ void Pickle::Reserve(size_t length) {
}
void Pickle::Resize(size_t new_capacity) {
- new_capacity = AlignInt(new_capacity, kPayloadUnit);
-
CHECK_NE(capacity_after_header_, kCapacityReadOnly);
- void* p = realloc(header_, header_size_ + new_capacity);
+ capacity_after_header_ = AlignInt(new_capacity, kPayloadUnit);
+ void* p = realloc(header_, GetTotalAllocatedSize());
CHECK(p);
header_ = reinterpret_cast<Header*>(p);
- capacity_after_header_ = new_capacity;
+}
+
+size_t Pickle::GetTotalAllocatedSize() const {
+ if (capacity_after_header_ == kCapacityReadOnly)
+ return 0;
+ return header_size_ + capacity_after_header_;
}
// static
« no previous file with comments | « base/pickle.h ('k') | base/port.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698