blob: 6eae42626bff9d55ab6e5398ffde3434619579ab [file] [log] [blame]
jbauch13041cf2016-02-25 06:16:52 -08001/*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "webrtc/base/copyonwritebuffer.h"
12
13namespace rtc {
14
15CopyOnWriteBuffer::CopyOnWriteBuffer() {
16 RTC_DCHECK(IsConsistent());
17}
18
19CopyOnWriteBuffer::CopyOnWriteBuffer(const CopyOnWriteBuffer& buf)
20 : buffer_(buf.buffer_) {
21}
22
danilchapd8a9c532016-07-30 12:39:26 -070023CopyOnWriteBuffer::CopyOnWriteBuffer(CopyOnWriteBuffer&& buf)
24 : buffer_(std::move(buf.buffer_)) {
jbauch13041cf2016-02-25 06:16:52 -080025}
26
27CopyOnWriteBuffer::CopyOnWriteBuffer(size_t size)
28 : buffer_(size > 0 ? new RefCountedObject<Buffer>(size) : nullptr) {
29 RTC_DCHECK(IsConsistent());
30}
31
32CopyOnWriteBuffer::CopyOnWriteBuffer(size_t size, size_t capacity)
33 : buffer_(size > 0 || capacity > 0
34 ? new RefCountedObject<Buffer>(size, capacity)
35 : nullptr) {
36 RTC_DCHECK(IsConsistent());
37}
38
39CopyOnWriteBuffer::~CopyOnWriteBuffer() = default;
40
41} // namespace rtc