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

@@ -356,18 +356,18 @@ static void readSection(FILE *file, struct Section *section, char const *fileNam
*/
static void linkSymToSect(struct Symbol &symbol, struct Section *section)
{
uint32_t a = 0, b = section->symbols->size();
uint32_t a = 0, b = section->symbols.size();
while (a != b) {
uint32_t c = (a + b) / 2;
if ((*section->symbols)[c]->offset > symbol.offset)
if (section->symbols[c]->offset > symbol.offset)
b = c;
else
a = c + 1;
}
section->symbols->insert(section->symbols->begin() + a, &symbol);
section->symbols.insert(section->symbols.begin() + a, &symbol);
}
/*
@@ -499,10 +499,7 @@ void obj_ReadFile(char const *fileName, unsigned int fileID)
fileSections[i]->nextu = NULL;
readSection(file, fileSections[i], fileName, nodes[fileID]);
fileSections[i]->fileSymbols = &fileSymbols;
fileSections[i]->symbols = new(std::nothrow) std::vector<struct Symbol *>();
if (!fileSections[i]->symbols)
err("%s: Failed to link to symbols", fileName);
fileSections[i]->symbols->reserve(nbSymPerSect[i]);
fileSections[i]->symbols.reserve(nbSymPerSect[i]);
sect_AddSection(fileSections[i]);
}
@@ -574,7 +571,6 @@ static void freeSection(struct Section *section)
if (sect_HasData(section->type))
delete section->data;
delete section->symbols;
delete section;
section = next;