diff options
author | Nick Kledzik <kledzik@apple.com> | 2014-02-06 23:48:52 +0000 |
---|---|---|
committer | Nick Kledzik <kledzik@apple.com> | 2014-02-06 23:48:52 +0000 |
commit | cdf2c8be58e53fb7eac7b2afea632fde168e867a (patch) | |
tree | ff10aa64cf7f5b0fb681a0eaf3ad3a2ad9c1cbad /lld/lib/ReaderWriter/MachO/File.h | |
parent | 803fb108744b2c8282f4f69781c603160822d096 (diff) | |
download | bcm5719-llvm-cdf2c8be58e53fb7eac7b2afea632fde168e867a.tar.gz bcm5719-llvm-cdf2c8be58e53fb7eac7b2afea632fde168e867a.zip |
[mach-o] use new way to copy StringRefs
llvm-svn: 200956
Diffstat (limited to 'lld/lib/ReaderWriter/MachO/File.h')
-rw-r--r-- | lld/lib/ReaderWriter/MachO/File.h | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/lld/lib/ReaderWriter/MachO/File.h b/lld/lib/ReaderWriter/MachO/File.h index f67e3f4db80..68aea4a042c 100644 --- a/lld/lib/ReaderWriter/MachO/File.h +++ b/lld/lib/ReaderWriter/MachO/File.h @@ -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); |