/*
- * Copyright 2016 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.
// Copyright 2013-present Facebook. All Rights Reserved.
// @author: Pavlo Kushnir (pavlo)
-#ifndef FOLLY_EXPERIMENTAL_STRINGKEYEDCOMMON_H_
-#define FOLLY_EXPERIMENTAL_STRINGKEYEDCOMMON_H_
+#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
-
-#endif /* FOLLY_EXPERIMENTAL_STRINGKEYEDCOMMON_H_ */
+} // namespace folly