Skip to content

Commit

Permalink
add checks
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Oct 10, 2023
1 parent f9e93b1 commit c489c9e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/cpp/lpnamer/helper/common_lpnamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ inline std::vector<std::string> split(const std::string& original,

inline FILE* OpenLogPtr(const std::filesystem::path& log_file) {
FILE* log_file_ptr = NULL;
if (log_file.empty()) {
return log_file_ptr;
}
#ifdef __linux__
if ((log_file_ptr = fopen(log_file.string().c_str(), "a+")) == nullptr)
#elif _WIN32
Expand Down
8 changes: 5 additions & 3 deletions src/cpp/multisolver_interface/SolverCbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ SolverCbc::~SolverCbc() {
}

void SolverCbc::set_fp(FILE *fp) {
setvbuf(fp, nullptr, _IONBF, 0);
_clp_inner_solver.messageHandler()->setFilePointer(fp);
_cbc.messageHandler()->setFilePointer(fp);
if (fp) {
setvbuf(fp, nullptr, _IONBF, 0);
_clp_inner_solver.messageHandler()->setFilePointer(fp);
_cbc.messageHandler()->setFilePointer(fp);
}
}

int SolverCbc::get_number_of_instances() { return _NumberOfProblems; }
Expand Down
6 changes: 4 additions & 2 deletions src/cpp/multisolver_interface/SolverClp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ SolverClp::~SolverClp() {
}

void SolverClp::set_fp(FILE *fp) {
setvbuf(_fp, nullptr, _IONBF, 0);
_clp.messageHandler()->setFilePointer(_fp);
if (fp) {
setvbuf(_fp, nullptr, _IONBF, 0);
_clp.messageHandler()->setFilePointer(_fp);
}
}

int SolverClp::get_number_of_instances() { return _NumberOfProblems; }
Expand Down

0 comments on commit c489c9e

Please sign in to comment.