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