| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/fixed_buffer.h" | 5 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 NOTREACHED(); | 32 NOTREACHED(); |
| 33 return nullptr; | 33 return nullptr; |
| 34 } | 34 } |
| 35 | 35 |
| 36 char* result = ptr_ + cursor_; | 36 char* result = ptr_ + cursor_; |
| 37 cursor_ += delta; | 37 cursor_ += delta; |
| 38 | 38 |
| 39 return result; | 39 return result; |
| 40 } | 40 } |
| 41 | 41 |
| 42 PickleBuffer* FixedBuffer::AsPickleBuffer() { return nullptr; } | |
| 43 | |
| 44 FixedBufferForTesting::FixedBufferForTesting(size_t size) { | 42 FixedBufferForTesting::FixedBufferForTesting(size_t size) { |
| 45 size_ = internal::Align(size); | 43 size_ = internal::Align(size); |
| 46 // Use calloc here to ensure all message memory is zero'd out. | 44 // Use calloc here to ensure all message memory is zero'd out. |
| 47 ptr_ = static_cast<char*>(calloc(size_, 1)); | 45 ptr_ = static_cast<char*>(calloc(size_, 1)); |
| 48 } | 46 } |
| 49 | 47 |
| 50 FixedBufferForTesting::~FixedBufferForTesting() { | 48 FixedBufferForTesting::~FixedBufferForTesting() { |
| 51 free(ptr_); | 49 free(ptr_); |
| 52 } | 50 } |
| 53 | 51 |
| 54 void* FixedBufferForTesting::Leak() { | 52 void* FixedBufferForTesting::Leak() { |
| 55 char* ptr = ptr_; | 53 char* ptr = ptr_; |
| 56 ptr_ = nullptr; | 54 ptr_ = nullptr; |
| 57 cursor_ = 0; | 55 cursor_ = 0; |
| 58 size_ = 0; | 56 size_ = 0; |
| 59 return ptr; | 57 return ptr; |
| 60 } | 58 } |
| 61 | 59 |
| 62 } // namespace internal | 60 } // namespace internal |
| 63 } // namespace mojo | 61 } // namespace mojo |
| OLD | NEW |