Add IOBufQueue::wrapBuffer, which handles buffers > 4GB.
[folly.git] / folly / experimental / io / IOBufQueue.cpp
index 4b6e5eab80589b2a4e7d42cec5d7355f371131c1..35295bf87fcba5ff1426d7580afe6192c272a7fe 100644 (file)
@@ -118,6 +118,17 @@ IOBufQueue::append(const void* buf, size_t len) {
   }
 }
 
+void
+IOBufQueue::wrapBuffer(const void* buf, size_t len, uint32_t blockSize) {
+  auto src = static_cast<const uint8_t*>(buf);
+  while (len != 0) {
+    size_t n = std::min(len, size_t(blockSize));
+    append(IOBuf::wrapBuffer(src, n));
+    src += n;
+    len -= n;
+  }
+}
+
 pair<void*,uint32_t>
 IOBufQueue::preallocate(uint32_t min, uint32_t max) {
   if (head_ != NULL) {