Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: webrtc/base/buffer.h

Issue 1707693002: Changed the semantics of Buffer::Clear to not alter the capacity (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@noogle-encode
Patch Set: Rebase onto correct branch. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/base/buffer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 174
175 // b.Pass() does the same thing as std::move(b). 175 // b.Pass() does the same thing as std::move(b).
176 // Deprecated; remove in March 2016 (bug 5373). 176 // Deprecated; remove in March 2016 (bug 5373).
177 RTC_DEPRECATED Buffer&& Pass() { return DEPRECATED_Pass(); } 177 RTC_DEPRECATED Buffer&& Pass() { return DEPRECATED_Pass(); }
178 Buffer&& DEPRECATED_Pass() { 178 Buffer&& DEPRECATED_Pass() {
179 assert(IsConsistent()); 179 assert(IsConsistent());
180 return std::move(*this); 180 return std::move(*this);
181 } 181 }
182 182
183 // Resets the buffer to zero size and capacity. Works even if the buffer has 183 // Resets the buffer to zero size without altering capacity. Works even if the
184 // been moved from. 184 // buffer has been moved from.
185 void Clear() { 185 void Clear() {
186 data_.reset();
187 size_ = 0; 186 size_ = 0;
188 capacity_ = 0;
189 assert(IsConsistent()); 187 assert(IsConsistent());
190 } 188 }
191 189
192 // Swaps two buffers. Also works for buffers that have been moved from. 190 // Swaps two buffers. Also works for buffers that have been moved from.
193 friend void swap(Buffer& a, Buffer& b) { 191 friend void swap(Buffer& a, Buffer& b) {
194 using std::swap; 192 using std::swap;
195 swap(a.size_, b.size_); 193 swap(a.size_, b.size_);
196 swap(a.capacity_, b.capacity_); 194 swap(a.capacity_, b.capacity_);
197 swap(a.data_, b.data_); 195 swap(a.data_, b.data_);
198 } 196 }
(...skipping 23 matching lines...) Expand all
222 } 220 }
223 221
224 size_t size_; 222 size_t size_;
225 size_t capacity_; 223 size_t capacity_;
226 std::unique_ptr<uint8_t[]> data_; 224 std::unique_ptr<uint8_t[]> data_;
227 }; 225 };
228 226
229 } // namespace rtc 227 } // namespace rtc
230 228
231 #endif // WEBRTC_BASE_BUFFER_H_ 229 #endif // WEBRTC_BASE_BUFFER_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698