Index: base/pickle.cc |
diff --git a/base/pickle.cc b/base/pickle.cc |
index af3191b9d86db2785fe375ecbcb045cf0a420870..4634561928de45f92ea2a127753ec6e089426da5 100644 |
--- a/base/pickle.cc |
+++ b/base/pickle.cc |
@@ -304,6 +304,16 @@ void Pickle::TrimWriteData(int new_length) { |
*cur_length = new_length; |
} |
+void Pickle::Reserve(size_t additional_capacity) { |
+ // write at a uint32-aligned offset from the beginning of the header |
jar (doing other things)
2013/10/25 01:54:18
nit: Start with Upper case, end with a period. (m
danakj
2013/10/25 18:40:47
Done.
|
+ size_t offset = AlignInt(header_->payload_size, sizeof(uint32)); |
+ |
+ size_t new_size = offset + additional_capacity; |
+ size_t needed_size = header_size_ + new_size; |
+ if (needed_size > capacity_) |
+ Resize(capacity_ * 2 + needed_size); |
jar (doing other things)
2013/10/25 01:54:18
Why did you double the existing capacity?
Also...
danakj
2013/10/25 18:40:47
For the same reason we double it in BeginWrite().
|
+} |
+ |
char* Pickle::BeginWrite(size_t length) { |
// write at a uint32-aligned offset from the beginning of the header |
size_t offset = AlignInt(header_->payload_size, sizeof(uint32)); |