/* * Copyright 2004 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef RTC_BASE_BUFFER_H_ #define RTC_BASE_BUFFER_H_ #include <stdint.h> #include <algorithm> #include <cstring> #include <memory> #include <type_traits> #include <utility> #include "absl/strings/string_view.h" #include "api/array_view.h" #include "rtc_base/checks.h" #include "rtc_base/type_traits.h" #include "rtc_base/zero_memory.h" namespace rtc { namespace internal { // (Internal; please don't use outside this file.) Determines if elements of // type U are compatible with a BufferT<T>. For most types, we just ignore // top-level const and forbid top-level volatile and require T and U to be // otherwise equal, but all byte-sized integers (notably char, int8_t, and // uint8_t) are compatible with each other. (Note: We aim to get rid of this // behavior, and treat all types the same.) template <typename T, typename U> struct BufferCompat { … }; } // namespace internal // Basic buffer class, can be grown and shrunk dynamically. // Unlike std::string/vector, does not initialize data when increasing size. // If "ZeroOnFree" is true, any memory is explicitly cleared before releasing. // The type alias "ZeroOnFreeBuffer" below should be used instead of setting // "ZeroOnFree" in the template manually to "true". template <typename T, bool ZeroOnFree = false> class BufferT { … }; // By far the most common sort of buffer. Buffer; // A buffer that zeros memory before releasing it. ZeroOnFreeBuffer; } // namespace rtc #endif // RTC_BASE_BUFFER_H_