#include <cstring>
#include <memory>
#include <limits>
+#include <sys/uio.h>
#include <type_traits>
#include <boost/iterator/iterator_facade.hpp>
#include "folly/FBString.h"
#include "folly/Range.h"
+#include "folly/FBVector.h"
+
+// Ignore shadowing warnings within this file, so includers can use -Wshadow.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
namespace folly {
*/
static std::unique_ptr<IOBuf> create(uint32_t capacity);
+ /**
+ * Allocate a new IOBuf chain with the requested total capacity, allocating
+ * no more than maxBufCapacity to each buffer.
+ */
+ static std::unique_ptr<IOBuf> createChain(
+ size_t totalCapacity, uint32_t maxBufCapacity);
+
/**
* Create a new IOBuf pointing to an existing data buffer.
*
*/
std::unique_ptr<IOBuf> cloneOne() const;
+ /**
+ * Return an iovector suitable for e.g. writev()
+ *
+ * auto iov = buf->getIov();
+ * auto xfer = writev(fd, iov.data(), iov.size());
+ *
+ * Naturally, the returned iovector is invalid if you modify the buffer
+ * chain.
+ */
+ folly::fbvector<struct iovec> getIov() const;
+
// Overridden operator new and delete.
// These directly use malloc() and free() to allocate the space for IOBuf
// objects. This is needed since IOBuf::create() manually uses malloc when
} // folly
+#pragma GCC diagnostic pop
+
#endif // FOLLY_IO_IOBUF_H_