Index: mojo/public/cpp/bindings/lib/scratch_buffer.cc |
diff --git a/mojo/public/cpp/bindings/lib/scratch_buffer.cc b/mojo/public/cpp/bindings/lib/scratch_buffer.cc |
index 9d23dcb13bba25b7b2dde5d1d5d5fc4f56847ca7..c7f507be285e921b81f710510535c9624311ddce 100644 |
--- a/mojo/public/cpp/bindings/lib/scratch_buffer.cc |
+++ b/mojo/public/cpp/bindings/lib/scratch_buffer.cc |
@@ -25,7 +25,7 @@ namespace internal { |
ScratchBuffer::ScratchBuffer() |
: overflow_(NULL) { |
fixed_.next = NULL; |
- fixed_.cursor = fixed_data_; |
+ fixed_.cursor = internal::AlignPointer(fixed_data_); |
darin (slow to review)
2014/05/06 07:32:55
maybe we should align fixed_.end too?
doesn't thi
darin (slow to review)
2014/05/06 07:35:29
nevermind. that would increase fixed_.end in some
yzshen1
2014/05/06 08:06:43
On 32-bit systems, it is possible that pointers ar
|
fixed_.end = fixed_data_ + kMinSegmentSize; |
} |
@@ -80,11 +80,12 @@ bool ScratchBuffer::AddOverflowSegment(size_t delta) { |
return false; |
// Ensure segment buffer is aligned. |
- size_t segment_size = internal::Align(sizeof(Segment)) + delta; |
- Segment* segment = static_cast<Segment*>(malloc(segment_size)); |
+ size_t padded_segment_size = internal::Align(sizeof(Segment)); |
+ Segment* segment = static_cast<Segment*>( |
+ malloc(padded_segment_size + delta)); |
if (segment) { |
segment->next = overflow_; |
- segment->cursor = reinterpret_cast<char*>(segment + 1); |
+ segment->cursor = reinterpret_cast<char*>(segment) + padded_segment_size; |
segment->end = segment->cursor + delta; |
overflow_ = segment; |
return true; |