OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2015 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/buffer.h" | |
12 | |
13 #include <algorithm> | |
14 #include <utility> | |
15 | |
16 namespace rtc { | |
17 | |
18 Buffer::Buffer() : size_(0), capacity_(0), data_(nullptr) { | |
19 RTC_DCHECK(IsConsistent()); | |
20 } | |
21 | |
22 Buffer::Buffer(Buffer&& buf) | |
23 : size_(buf.size()), | |
24 capacity_(buf.capacity()), | |
25 data_(std::move(buf.data_)) { | |
26 RTC_DCHECK(IsConsistent()); | |
27 buf.OnMovedFrom(); | |
28 } | |
29 | |
30 Buffer::Buffer(size_t size) : Buffer(size, size) { | |
31 } | |
32 | |
33 Buffer::Buffer(size_t size, size_t capacity) | |
34 : size_(size), | |
35 capacity_(std::max(size, capacity)), | |
36 data_(new uint8_t[capacity_]) { | |
37 RTC_DCHECK(IsConsistent()); | |
38 } | |
39 | |
40 // Note: The destructor works even if the buffer has been moved from. | |
41 Buffer::~Buffer() = default; | |
42 | |
43 }; // namespace rtc | |
OLD | NEW |