mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Basic] Move copyCString to Basic/StringExtras.
Also, use StringRef.copy() instead of copyString().
This commit is contained in:
@@ -457,10 +457,14 @@ StringRef swift::matchLeadingTypeName(StringRef name,
|
||||
return nameMismatch.getRestOfStr();
|
||||
}
|
||||
|
||||
StringRef StringScratchSpace::copyString(StringRef string) {
|
||||
void *memory = Allocator.Allocate(string.size(), alignof(char));
|
||||
const char *swift::copyCString(StringRef string,
|
||||
llvm::BumpPtrAllocator &Allocator) {
|
||||
if (string.empty())
|
||||
return "";
|
||||
char *memory = Allocator.Allocate<char>(string.size() + 1);
|
||||
memcpy(memory, string.data(), string.size());
|
||||
return StringRef(static_cast<char *>(memory), string.size());
|
||||
memory[string.size()] = '\0';
|
||||
return memory;
|
||||
}
|
||||
|
||||
void InheritedNameSet::add(StringRef name) {
|
||||
|
||||
Reference in New Issue
Block a user