#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif
#include <folly/io/IOBuf.h>
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <limits>
#include <stdexcept>
#include <type_traits>
#include <folly/Conv.h>
#include <folly/Likely.h>
#include <folly/Memory.h>
#include <folly/ScopeGuard.h>
#include <folly/hash/SpookyHashV2.h>
#include <folly/io/Cursor.h>
#include <folly/lang/Align.h>
#include <folly/lang/CheckedMath.h>
#include <folly/lang/Exception.h>
#include <folly/lang/Hint.h>
#include <folly/memory/Malloc.h>
#include <folly/memory/SanitizeAddress.h>
#if FOLLY_HAVE_WEAK_SYMBOLS
FOLLY_ATTR_WEAK void io_buf_alloc_cb(void* , size_t ) noexcept;
FOLLY_ATTR_WEAK void io_buf_free_cb(void* , size_t ) noexcept;
#else
static void (*io_buf_alloc_cb)(void* , size_t ) noexcept = …;
static void (*io_buf_free_cb)(void* , size_t ) noexcept = …;
#endif
unique_ptr;
namespace {
constexpr uint16_t kHeapMagic = …;
constexpr size_t kDefaultCombinedBufSize = …;
constexpr size_t kMaxIOBufSize = …;
void takeOwnershipError(
bool freeOnError,
void* buf,
folly::IOBuf::FreeFunction freeFn,
void* userData) noexcept { … }
}
namespace folly {
struct IOBuf::HeapPrefix { … };
struct IOBuf::HeapStorage { … };
struct alignas(folly::max_align_v) IOBuf::HeapFullStorage { … };
constexpr uint8_t kHeapStorageRefcount = …;
constexpr uint8_t kHeapFullStorageRefcount = …;
IOBuf::SharedInfo::SharedInfo(FreeFunction fn, void* arg, StorageType st)
: … { … }
void IOBuf::SharedInfo::invokeAndDeleteEachObserver(
SharedInfoObserverEntryBase* observerListHead, ObserverCb cb) noexcept { … }
void IOBuf::SharedInfo::releaseStorage(
IOBuf* parent, StorageType storageType, SharedInfo* info) noexcept { … }
void* IOBuf::operator new(size_t size) { … }
void* IOBuf::operator new(size_t , void* ptr) { … }
void IOBuf::operator delete(void* ptr) { … }
void IOBuf::operator delete(void* , void* ) { … }
void IOBuf::decrementStorageRefcount(HeapStorage* storage) noexcept { … }
IOBuf::IOBuf(CreateOp, std::size_t capacity)
: … { … }
IOBuf::IOBuf(
CopyBufferOp ,
const void* buf,
std::size_t size,
std::size_t headroom,
std::size_t minTailroom)
: … { … }
IOBuf::IOBuf(
CopyBufferOp op,
ByteRange br,
std::size_t headroom,
std::size_t minTailroom)
: … { … }
unique_ptr<IOBuf> IOBuf::create(std::size_t capacity) { … }
unique_ptr<IOBuf> IOBuf::createCombined(std::size_t capacity) { … }
unique_ptr<IOBuf> IOBuf::createSeparate(std::size_t capacity) { … }
unique_ptr<IOBuf> IOBuf::createChain(
size_t totalCapacity, std::size_t maxBufCapacity) { … }
size_t IOBuf::goodSize(size_t minCapacity, CombinedOption combined) { … }
IOBuf::IOBuf(
TakeOwnershipOp,
void* buf,
std::size_t capacity,
std::size_t offset,
std::size_t length,
FreeFunction freeFn,
void* userData,
bool freeOnError)
: … { … }
IOBuf::IOBuf(
TakeOwnershipOp,
SizedFree,
void* buf,
std::size_t capacity,
std::size_t offset,
std::size_t length,
bool freeOnError)
: … { … }
unique_ptr<IOBuf> IOBuf::takeOwnership(
void* buf,
std::size_t capacity,
std::size_t offset,
std::size_t length,
FreeFunction freeFn,
void* userData,
bool freeOnError,
TakeOwnershipOption option) { … }
IOBuf::IOBuf(WrapBufferOp, const void* buf, std::size_t capacity) noexcept
: … { … }
IOBuf::IOBuf(WrapBufferOp op, ByteRange br) noexcept
: … { … }
unique_ptr<IOBuf> IOBuf::wrapBuffer(const void* buf, std::size_t capacity) { … }
IOBuf IOBuf::wrapBufferAsValue(const void* buf, std::size_t capacity) noexcept { … }
IOBuf::IOBuf() noexcept = default;
IOBuf::IOBuf(IOBuf&& other) noexcept
: … { … }
IOBuf::IOBuf(const IOBuf& other) { … }
IOBuf::IOBuf(
InternalConstructor,
SharedInfo* sharedInfo,
uint8_t* buf,
std::size_t capacity,
uint8_t* data,
std::size_t length) noexcept
: … { … }
IOBuf::~IOBuf() { … }
IOBuf& IOBuf::operator=(IOBuf&& other) noexcept { … }
IOBuf& IOBuf::operator=(const IOBuf& other) { … }
bool IOBuf::empty() const { … }
size_t IOBuf::countChainElements() const { … }
std::size_t IOBuf::computeChainDataLength() const { … }
std::size_t IOBuf::computeChainCapacity() const { … }
void IOBuf::appendToChain(unique_ptr<IOBuf>&& iobuf) { … }
unique_ptr<IOBuf> IOBuf::clone() const { … }
unique_ptr<IOBuf> IOBuf::cloneOne() const { … }
unique_ptr<IOBuf> IOBuf::cloneCoalesced() const { … }
unique_ptr<IOBuf> IOBuf::cloneCoalescedWithHeadroomTailroom(
std::size_t newHeadroom, std::size_t newTailroom) const { … }
IOBuf IOBuf::cloneAsValue() const { … }
IOBuf IOBuf::cloneOneAsValue() const { … }
IOBuf IOBuf::cloneCoalescedAsValue() const { … }
IOBuf IOBuf::cloneCoalescedAsValueWithHeadroomTailroom(
std::size_t newHeadroom, std::size_t newTailroom) const { … }
std::unique_ptr<IOBuf> IOBuf::maybeSplitTail() { … }
void IOBuf::unshareOneSlow() { … }
void IOBuf::unshareChained() { … }
void IOBuf::markExternallyShared() { … }
void IOBuf::makeManagedChained() { … }
void IOBuf::coalesceSlow() { … }
void IOBuf::coalesceSlow(size_t maxLength) { … }
void IOBuf::coalesceAndReallocate(
size_t newHeadroom, size_t newLength, IOBuf* end, size_t newTailroom) { … }
void IOBuf::decrementRefcount() noexcept { … }
void IOBuf::reserveSlow(std::size_t minHeadroom, std::size_t minTailroom) { … }
void IOBuf::freeExtBuffer() noexcept { … }
void IOBuf::allocExtBuffer(
std::size_t minCapacity,
uint8_t** bufReturn,
SharedInfo** infoReturn,
std::size_t* capacityReturn) { … }
size_t IOBuf::goodExtBufferSize(std::size_t minCapacity) { … }
void IOBuf::initExtBuffer(
uint8_t* buf,
size_t mallocSize,
SharedInfo** infoReturn,
std::size_t* capacityReturn) { … }
fbstring IOBuf::moveToFbString() { … }
IOBuf::Iterator IOBuf::cbegin() const { … }
IOBuf::Iterator IOBuf::cend() const { … }
folly::fbvector<struct iovec> IOBuf::getIov() const { … }
void IOBuf::appendToIov(folly::fbvector<struct iovec>* iov) const { … }
unique_ptr<IOBuf> IOBuf::wrapIov(const iovec* vec, size_t count) { … }
std::unique_ptr<IOBuf> IOBuf::takeOwnershipIov(
const iovec* vec,
size_t count,
FreeFunction freeFn,
void* userData,
bool freeOnError) { … }
IOBuf::FillIovResult IOBuf::fillIov(struct iovec* iov, size_t len) const { … }
uint32_t IOBuf::approximateShareCountOne() const { … }
size_t IOBufHash::operator()(const IOBuf& buf) const noexcept { … }
ordering IOBufCompare::impl(const IOBuf& a, const IOBuf& b) const noexcept { … }
}