mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Use std::vector<char *> instead of array in gamecontext
This commit is contained in:
parent
80103888ea
commit
0f097a0490
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue