mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-14 03:58:18 +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;
|
CLineReader LineReader;
|
||||||
LineReader.Init(File);
|
LineReader.Init(File);
|
||||||
|
|
||||||
array<char *> aLines;
|
std::vector<char *> vLines;
|
||||||
char *pLine;
|
char *pLine;
|
||||||
int TotalLength = 0;
|
int TotalLength = 0;
|
||||||
while((pLine = LineReader.Get()))
|
while((pLine = LineReader.Get()))
|
||||||
|
@ -3524,19 +3524,19 @@ void CGameContext::OnMapChange(char *pNewMapName, int MapNameSize)
|
||||||
int Length = str_length(pLine) + 1;
|
int Length = str_length(pLine) + 1;
|
||||||
char *pCopy = (char *)malloc(Length);
|
char *pCopy = (char *)malloc(Length);
|
||||||
mem_copy(pCopy, pLine, Length);
|
mem_copy(pCopy, pLine, Length);
|
||||||
aLines.add(pCopy);
|
vLines.push_back(pCopy);
|
||||||
TotalLength += Length;
|
TotalLength += Length;
|
||||||
}
|
}
|
||||||
io_close(File);
|
io_close(File);
|
||||||
|
|
||||||
char *pSettings = (char *)malloc(maximum(1, TotalLength));
|
char *pSettings = (char *)malloc(maximum(1, TotalLength));
|
||||||
int Offset = 0;
|
int Offset = 0;
|
||||||
for(int i = 0; i < aLines.size(); i++)
|
for(auto &Line : vLines)
|
||||||
{
|
{
|
||||||
int Length = str_length(aLines[i]) + 1;
|
int Length = str_length(Line) + 1;
|
||||||
mem_copy(pSettings + Offset, aLines[i], Length);
|
mem_copy(pSettings + Offset, Line, Length);
|
||||||
Offset += Length;
|
Offset += Length;
|
||||||
free(aLines[i]);
|
free(Line);
|
||||||
}
|
}
|
||||||
|
|
||||||
CDataFileReader Reader;
|
CDataFileReader Reader;
|
||||||
|
|
Loading…
Reference in a new issue