/*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2015-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#pragma once
#include <memory>
+
#include <folly/Range.h>
namespace folly {
auto size = piece.size();
auto keyDup = typename Alloc::template rebind<char>::other(alloc)
.allocate(size);
- memcpy(keyDup, piece.data(), size * sizeof(typename StringPiece::value_type));
+ if (size) {
+ memcpy(
+ keyDup, piece.data(), size * sizeof(typename StringPiece::value_type));
+ }
return StringPiece(keyDup, size);
}
.deallocate(const_cast<char*>(piece.data()), piece.size());
}
-} // folly
+} // namespace folly