Use std::vector<char *> instead of array in gamecontext

This commit is contained in:
Robert Müller 2022-05-23 23:03:52 +02:00
parent 80103888ea
commit 0f097a0490

View file

@ -3516,7 +3516,7 @@ void CGameContext::OnMapChange(char *pNewMapName, int MapNameSize)
CLineReader LineReader;
LineReader.Init(File);
array<char *> aLines;
std::vector<char *> vLines;
char *pLine;
int TotalLength = 0;
while((pLine = LineReader.Get()))
@ -3524,19 +3524,19 @@ void CGameContext::OnMapChange(char *pNewMapName, int MapNameSize)
int Length = str_length(pLine) + 1;
char *pCopy = (char *)malloc(Length);
mem_copy(pCopy, pLine, Length);
aLines.add(pCopy);
vLines.push_back(pCopy);
TotalLength += Length;
}
io_close(File);
char *pSettings = (char *)malloc(maximum(1, TotalLength));
int Offset = 0;
for(int i = 0; i < aLines.size(); i++)
for(auto &Line : vLines)
{
int Length = str_length(aLines[i]) + 1;
mem_copy(pSettings + Offset, aLines[i], Length);
int Length = str_length(Line) + 1;
mem_copy(pSettings + Offset, Line, Length);
Offset += Length;
free(aLines[i]);
free(Line);
}
CDataFileReader Reader;