Program::RemoveFixedBlocks -> Program::CreateReducedProgram.

CreateReducedProgram is a safer API, reduces the possibility of
memory leaks and produces valid programs.

Change-Id: I094d53d207fced970a4d9ea0b66cdb09ce5f0657
This commit is contained in:
Sameer Agarwal
2014-06-01 14:47:22 -07:00
parent 29fe072781
commit b4a5f7ea25
4 changed files with 132 additions and 78 deletions
+18
View File
@@ -261,6 +261,24 @@ bool Program::IsFeasible(string* message) const {
return true;
}
Program* Program::CreateReducedProgram(vector<double*>* removed_parameter_blocks,
double* fixed_cost,
string* error) const {
CHECK_NOTNULL(removed_parameter_blocks);
CHECK_NOTNULL(fixed_cost);
CHECK_NOTNULL(error);
scoped_ptr<Program> reduced_program(new Program(*this));
if (!reduced_program->RemoveFixedBlocks(removed_parameter_blocks,
fixed_cost,
error)) {
return NULL;
}
reduced_program->SetParameterOffsetsAndIndex();
return reduced_program.release();
}
bool Program::RemoveFixedBlocks(vector<double*>* removed_parameter_blocks,
double* fixed_cost,
string* error) {