BUG: Do not use std::string to accumulate output. Use std::vector instead. This is much better at memory management.
This commit is contained in:
parent
6018ebdc85
commit
945fcb581d
|
@ -2432,6 +2432,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output,
|
||||||
|
|
||||||
int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, int *retVal)
|
int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, int *retVal)
|
||||||
{
|
{
|
||||||
|
std::vector<char> tempOutput;
|
||||||
if ( output )
|
if ( output )
|
||||||
{
|
{
|
||||||
*output = "";
|
*output = "";
|
||||||
|
@ -2454,7 +2455,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, int *re
|
||||||
{
|
{
|
||||||
if ( output )
|
if ( output )
|
||||||
{
|
{
|
||||||
output->append(data, length);
|
tempOutput.insert(tempOutput.end(), data, data+length);
|
||||||
}
|
}
|
||||||
if ( m_Verbose )
|
if ( m_Verbose )
|
||||||
{
|
{
|
||||||
|
@ -2464,6 +2465,10 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, int *re
|
||||||
}
|
}
|
||||||
|
|
||||||
cmsysProcess_WaitForExit(cp, 0);
|
cmsysProcess_WaitForExit(cp, 0);
|
||||||
|
if(output)
|
||||||
|
{
|
||||||
|
output->append(&*tempOutput.begin(), tempOutput.size());
|
||||||
|
}
|
||||||
|
|
||||||
int result = cmsysProcess_GetState(cp);
|
int result = cmsysProcess_GetState(cp);
|
||||||
|
|
||||||
|
|
|
@ -400,6 +400,7 @@ bool cmSystemTools::RunSingleCommand(
|
||||||
cmsysProcess_SetTimeout(cp, timeout);
|
cmsysProcess_SetTimeout(cp, timeout);
|
||||||
cmsysProcess_Execute(cp);
|
cmsysProcess_Execute(cp);
|
||||||
|
|
||||||
|
std::vector<char> tempOutput;
|
||||||
char* data;
|
char* data;
|
||||||
int length;
|
int length;
|
||||||
while(cmsysProcess_WaitForData(cp, (cmsysProcess_Pipe_STDOUT |
|
while(cmsysProcess_WaitForData(cp, (cmsysProcess_Pipe_STDOUT |
|
||||||
|
@ -408,7 +409,7 @@ bool cmSystemTools::RunSingleCommand(
|
||||||
{
|
{
|
||||||
if ( output )
|
if ( output )
|
||||||
{
|
{
|
||||||
output->append(data, length);
|
tempOutput.insert(tempOutput.end(), data, data+length);
|
||||||
}
|
}
|
||||||
if(verbose)
|
if(verbose)
|
||||||
{
|
{
|
||||||
|
@ -417,6 +418,10 @@ bool cmSystemTools::RunSingleCommand(
|
||||||
}
|
}
|
||||||
|
|
||||||
cmsysProcess_WaitForExit(cp, 0);
|
cmsysProcess_WaitForExit(cp, 0);
|
||||||
|
if ( output )
|
||||||
|
{
|
||||||
|
output->append(&*tempOutput.begin(), tempOutput.size());
|
||||||
|
}
|
||||||
|
|
||||||
bool result = true;
|
bool result = true;
|
||||||
if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exited)
|
if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exited)
|
||||||
|
|
Loading…
Reference in New Issue