uint64_t capacity = headroom + size + minTailroom;
std::unique_ptr<IOBuf> buf = create(capacity);
buf->advance(headroom);
uint64_t capacity = headroom + size + minTailroom;
std::unique_ptr<IOBuf> buf = create(capacity);
buf->advance(headroom);
- memcpy(buf->writableData(), data, size);
+ if (size != 0) {
+ memcpy(buf->writableData(), data, size);
+ }
buf->append(size);
return buf;
}
buf->append(size);
return buf;
}
EXPECT_EQ(nullptr, buf.get());
}
EXPECT_EQ(nullptr, buf.get());
}
+TEST(IOBuf, copyEmptyBuffer) {
+ auto buf = IOBuf::copyBuffer(nullptr, 0);
+ EXPECT_EQ(buf->length(), 0);
+}
+
namespace {
int customDeleterCount = 0;
namespace {
int customDeleterCount = 0;