Use automatic allocation for section symbols

This commit is contained in:
Rangi42
2024-02-28 19:11:06 -05:00
committed by Sylvie
parent 5a26a48d11
commit 826512730c
4 changed files with 10 additions and 18 deletions

View File

@@ -340,10 +340,6 @@ void sdobj_ReadFile(struct FileStackNode const *where, FILE *file, std::vector<s
// The array will be allocated if the section does contain data
curSection->data = NULL;
curSection->fileSymbols = &fileSymbols; // IDs are instead per-section
curSection->symbols = new(std::nothrow) std::vector<struct Symbol *>();
if (!curSection->symbols)
fatal(where, lineNo, "Failed to alloc new area's symbol list: %s",
strerror(errno));
curSection->nextu = NULL;
break;
}
@@ -409,7 +405,7 @@ void sdobj_ReadFile(struct FileStackNode const *where, FILE *file, std::vector<s
fatal(where, lineNo, "'S' line is neither \"Def\" nor \"Ref\"");
if (!fileSections.empty())
fileSections.back().section->symbols->push_back(&symbol);
fileSections.back().section->symbols.push_back(&symbol);
expectEol("'S' line is too long");
break;
@@ -730,7 +726,7 @@ void sdobj_ReadFile(struct FileStackNode const *where, FILE *file, std::vector<s
if (section->modifier == SECTION_FRAGMENT) {
// Add the fragment's offset to all of its symbols
for (struct Symbol *symbol : *section->symbols)
for (struct Symbol *symbol : section->symbols)
symbol->offset += section->offset;
}
}