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

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

Issue 2384693002: Test RTC_DCHECK_IS_ON instead of checking DCHECK_ALWAYS_ON everywhere (Closed)
Patch Set: !!! Created 4 years, 2 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 | « webrtc/api/statstypes.cc ('k') | webrtc/base/checks.h » ('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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // Postcondition for all methods except move construction and move 342 // Postcondition for all methods except move construction and move
343 // assignment, which leave the moved-from object in a possibly inconsistent 343 // assignment, which leave the moved-from object in a possibly inconsistent
344 // state. 344 // state.
345 bool IsConsistent() const { 345 bool IsConsistent() const {
346 return (data_ || capacity_ == 0) && capacity_ >= size_; 346 return (data_ || capacity_ == 0) && capacity_ >= size_;
347 } 347 }
348 348
349 // Called when *this has been moved from. Conceptually it's a no-op, but we 349 // Called when *this has been moved from. Conceptually it's a no-op, but we
350 // can mutate the state slightly to help subsequent sanity checks catch bugs. 350 // can mutate the state slightly to help subsequent sanity checks catch bugs.
351 void OnMovedFrom() { 351 void OnMovedFrom() {
352 #ifdef NDEBUG 352 #if RTC_DCHECK_IS_ON
353 // Make *this consistent and empty. Shouldn't be necessary, but better safe 353 // Make *this consistent and empty. Shouldn't be necessary, but better safe
354 // than sorry. 354 // than sorry.
355 size_ = 0; 355 size_ = 0;
356 capacity_ = 0; 356 capacity_ = 0;
357 #else 357 #else
358 // Ensure that *this is always inconsistent, to provoke bugs. 358 // Ensure that *this is always inconsistent, to provoke bugs.
359 size_ = 1; 359 size_ = 1;
360 capacity_ = 0; 360 capacity_ = 0;
361 #endif 361 #endif
362 } 362 }
363 363
364 size_t size_; 364 size_t size_;
365 size_t capacity_; 365 size_t capacity_;
366 std::unique_ptr<T[]> data_; 366 std::unique_ptr<T[]> data_;
367 }; 367 };
368 368
369 // By far the most common sort of buffer. 369 // By far the most common sort of buffer.
370 using Buffer = BufferT<uint8_t>; 370 using Buffer = BufferT<uint8_t>;
371 371
372 } // namespace rtc 372 } // namespace rtc
373 373
374 #endif // WEBRTC_BASE_BUFFER_H_ 374 #endif // WEBRTC_BASE_BUFFER_H_
OLDNEW
« no previous file with comments | « webrtc/api/statstypes.cc ('k') | webrtc/base/checks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698