| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/public/cpp/bindings/lib/pickle_buffer.h" | 5 #include "mojo/public/cpp/bindings/lib/pickle_buffer.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h" | 10 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 | 33 |
| 34 void* PickleBuffer::Allocate(size_t num_bytes) { | 34 void* PickleBuffer::Allocate(size_t num_bytes) { |
| 35 // The last allocation may terminate in between 8-byte boundaries. Pad the | 35 // The last allocation may terminate in between 8-byte boundaries. Pad the |
| 36 // front of this allocation if that's the case. | 36 // front of this allocation if that's the case. |
| 37 size_t padding_bytes = (8 - (payload_size() % 8)) % 8; | 37 size_t padding_bytes = (8 - (payload_size() % 8)) % 8; |
| 38 char* p = reinterpret_cast<char*>(ClaimBytes(padding_bytes + num_bytes)); | 38 char* p = reinterpret_cast<char*>(ClaimBytes(padding_bytes + num_bytes)); |
| 39 return p + padding_bytes; | 39 return p + padding_bytes; |
| 40 } | 40 } |
| 41 | 41 |
| 42 PickleBuffer* PickleBuffer::AsPickleBuffer() { return this; } |
| 43 |
| 42 } // namespace internal | 44 } // namespace internal |
| 43 } // namespace mojo | 45 } // namespace mojo |
| OLD | NEW |