forked from OSchip/llvm-project
[mach-o] fix leak in atoms -> normalized
llvm-svn: 223530
This commit is contained in:
parent
b7ec8ae2ab
commit
e5da30cbd3
|
@ -95,6 +95,7 @@ class Util {
|
||||||
public:
|
public:
|
||||||
Util(const MachOLinkingContext &ctxt)
|
Util(const MachOLinkingContext &ctxt)
|
||||||
: _context(ctxt), _archHandler(ctxt.archHandler()), _entryAtom(nullptr) {}
|
: _context(ctxt), _archHandler(ctxt.archHandler()), _entryAtom(nullptr) {}
|
||||||
|
~Util();
|
||||||
|
|
||||||
void assignAtomsToSections(const lld::File &atomFile);
|
void assignAtomsToSections(const lld::File &atomFile);
|
||||||
void organizeSections();
|
void organizeSections();
|
||||||
|
@ -170,6 +171,22 @@ private:
|
||||||
std::vector<const Atom *> _machHeaderAliasAtoms;
|
std::vector<const Atom *> _machHeaderAliasAtoms;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Util::~Util() {
|
||||||
|
// The SectionInfo structs are BumpPtr allocated, but atomsAndOffsets needs
|
||||||
|
// to be deleted.
|
||||||
|
for (SectionInfo *si : _sectionInfos) {
|
||||||
|
// clear() destroys vector elements, but does not deallocate.
|
||||||
|
// Instead use swap() to deallocate vector buffer.
|
||||||
|
std::vector<AtomInfo> empty;
|
||||||
|
si->atomsAndOffsets.swap(empty);
|
||||||
|
}
|
||||||
|
// The SegmentInfo structs are BumpPtr allocated, but sections needs
|
||||||
|
// to be deleted.
|
||||||
|
for (SegmentInfo *sgi : _segmentInfos) {
|
||||||
|
std::vector<SectionInfo*> empty2;
|
||||||
|
sgi->sections.swap(empty2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SectionInfo *Util::getRelocatableSection(DefinedAtom::ContentType type) {
|
SectionInfo *Util::getRelocatableSection(DefinedAtom::ContentType type) {
|
||||||
StringRef segmentName;
|
StringRef segmentName;
|
||||||
|
|
Loading…
Reference in New Issue