OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 scoped_ptr<uint8_t[]> new_data(new uint8_t[capacity]); | 165 scoped_ptr<uint8_t[]> new_data(new uint8_t[capacity]); |
166 std::memcpy(new_data.get(), data_.get(), size_); | 166 std::memcpy(new_data.get(), data_.get(), size_); |
167 data_ = std::move(new_data); | 167 data_ = std::move(new_data); |
168 capacity_ = capacity; | 168 capacity_ = capacity; |
169 assert(IsConsistent()); | 169 assert(IsConsistent()); |
170 } | 170 } |
171 | 171 |
172 // b.Pass() does the same thing as std::move(b). | 172 // b.Pass() does the same thing as std::move(b). |
173 Buffer&& Pass() { | 173 Buffer&& Pass() { |
174 assert(IsConsistent()); | 174 assert(IsConsistent()); |
175 return static_cast<Buffer&&>(*this); | 175 return std::move(*this); |
176 } | 176 } |
177 | 177 |
178 // Resets the buffer to zero size and capacity. Works even if the buffer has | 178 // Resets the buffer to zero size and capacity. Works even if the buffer has |
179 // been moved from. | 179 // been moved from. |
180 void Clear() { | 180 void Clear() { |
181 data_.reset(); | 181 data_.reset(); |
182 size_ = 0; | 182 size_ = 0; |
183 capacity_ = 0; | 183 capacity_ = 0; |
184 assert(IsConsistent()); | 184 assert(IsConsistent()); |
185 } | 185 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 217 } |
218 | 218 |
219 size_t size_; | 219 size_t size_; |
220 size_t capacity_; | 220 size_t capacity_; |
221 scoped_ptr<uint8_t[]> data_; | 221 scoped_ptr<uint8_t[]> data_; |
222 }; | 222 }; |
223 | 223 |
224 } // namespace rtc | 224 } // namespace rtc |
225 | 225 |
226 #endif // WEBRTC_BASE_BUFFER_H_ | 226 #endif // WEBRTC_BASE_BUFFER_H_ |
OLD | NEW |