diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-07-11 23:15:05 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-07-11 23:15:05 +0000 |
commit | 7172b38af7ed5d1c1e2c97fadfb0ae0c19aff816 (patch) | |
tree | 3daaa83d240f35df317d07b996842debd903bcaa /tools | |
parent | 459d7bf8f6f1577c67d50c060bff7115d30f9fb9 (diff) | |
download | external_llvm-7172b38af7ed5d1c1e2c97fadfb0ae0c19aff816.zip external_llvm-7172b38af7ed5d1c1e2c97fadfb0ae0c19aff816.tar.gz external_llvm-7172b38af7ed5d1c1e2c97fadfb0ae0c19aff816.tar.bz2 |
llvm-ar: Clean up memory management with OwningPtr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186131 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvm-ar/ArchiveReader.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/tools/llvm-ar/ArchiveReader.cpp b/tools/llvm-ar/ArchiveReader.cpp index 4a79a3a..a041cb8 100644 --- a/tools/llvm-ar/ArchiveReader.cpp +++ b/tools/llvm-ar/ArchiveReader.cpp @@ -212,7 +212,7 @@ Archive::loadArchive(std::string* error) { while (At < End) { // parse the member header const char* Save = At; - ArchiveMember* mbr = parseMemberHeader(At, End, error); + OwningPtr<ArchiveMember> mbr(parseMemberHeader(At, End, error)); if (!mbr) return false; @@ -230,7 +230,6 @@ Archive::loadArchive(std::string* error) { At += mbr->getSize(); if ((intptr_t(At) & 1) == 1) At++; - delete mbr; } else { // This is just a regular file. If its the first one, save its offset. // Otherwise just push it on the list and move on to the next file. @@ -238,8 +237,8 @@ Archive::loadArchive(std::string* error) { firstFileOffset = Save - base; foundFirstFile = true; } - members.push_back(mbr); At += mbr->getSize(); + members.push_back(mbr.take()); if ((intptr_t(At) & 1) == 1) At++; } @@ -276,7 +275,7 @@ Archive::loadSymbolTable(std::string* ErrorMsg) { // Parse the first file member header const char* FirstFile = At; - ArchiveMember* mbr = parseMemberHeader(At, End, ErrorMsg); + OwningPtr<ArchiveMember> mbr(parseMemberHeader(At, End, ErrorMsg)); if (!mbr) return false; @@ -285,15 +284,12 @@ Archive::loadSymbolTable(std::string* ErrorMsg) { At += mbr->getSize(); if ((intptr_t(At) & 1) == 1) At++; - delete mbr; // Read the next one FirstFile = At; - mbr = parseMemberHeader(At, End, ErrorMsg); - if (!mbr) { - delete mbr; + mbr.reset(parseMemberHeader(At, End, ErrorMsg)); + if (!mbr) return false; - } } if (mbr->isStringTable()) { @@ -302,21 +298,19 @@ Archive::loadSymbolTable(std::string* ErrorMsg) { At += mbr->getSize(); if ((intptr_t(At) & 1) == 1) At++; - delete mbr; + // Get the next one FirstFile = At; - mbr = parseMemberHeader(At, End, ErrorMsg); - if (!mbr) { - delete mbr; + mbr.reset(parseMemberHeader(At, End, ErrorMsg)); + if (!mbr) return false; - } } // There's no symbol table in the file. We have to rebuild it from scratch // because the intent of this method is to get the symbol table loaded so // it can be searched efficiently. // Add the member to the members list - members.push_back(mbr); + members.push_back(mbr.take()); firstFileOffset = FirstFile - base; return true; |