[mach-o] use new way to copy StringRefs

llvm-svn: 200956
This commit is contained in:
Nick Kledzik 2014-02-06 23:48:52 +00:00
parent 803fb10874
commit cdf2c8be58
1 changed files with 4 additions and 10 deletions

View File

@ -25,12 +25,8 @@ public:
Atom::Scope scope, bool copyRefs) {
if (copyRefs) {
// Make a copy of the atom's name and content that is owned by this file.
char *s = _allocator.Allocate<char>(name.size());
memcpy(s, name.data(), name.size());
name = StringRef(s, name.size());
uint8_t *bytes = _allocator.Allocate<uint8_t>(content.size());
memcpy(bytes, content.data(), content.size());
content = llvm::makeArrayRef(bytes, content.size());
name = name.copy(_allocator);
content = content.copy(_allocator);
}
MachODefinedAtom *atom =
new (_allocator) MachODefinedAtom(*this, name, content, scope);
@ -39,10 +35,8 @@ public:
void addUndefinedAtom(StringRef name, bool copyRefs) {
if (copyRefs) {
// Make a copy of the atom's name and content that is owned by this file.
char *s = _allocator.Allocate<char>(name.size());
memcpy(s, name.data(), name.size());
name = StringRef(s, name.size());
// Make a copy of the atom's name that is owned by this file.
name = name.copy(_allocator);
}
SimpleUndefinedAtom *atom =
new (_allocator) SimpleUndefinedAtom(*this, name);