[Clp-tickets] [COIN-OR Linear Programming Solver] #44: change max characters in Clp_problem name

COIN-OR Linear Programming Solver coin-trac at coin-or.org
Fri Mar 4 11:36:44 EST 2011


#44: change max characters in Clp_problem name
------------------------+---------------------------------------------------
 Reporter:  kmartin     |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  minor       |   Milestone:          
Component:  component1  |     Version:          
 Keywords:              |  
------------------------+---------------------------------------------------
 /*
 **  ORIGINAL VERSION
 **  From Clp_C_Interface.cpp
 */

 /* Fills in array with problem name  */
 COINLIBAPI void COINLINKAGE
 Clp_problemName(Clp_Simplex * model, int maxNumberCharacters, char *
 array)
 {
   std::string name = model->model_->problemName();
   maxNumberCharacters =
 CoinMin(maxNumberCharacters,(int)strlen(name.c_str()));
   strncpy(array,name.c_str(),maxNumberCharacters-1);
   array[maxNumberCharacters-1]='\0';
 }

 /*
 **  maxNumberCharacters should be allowed to be
 1+(int)strlen(name.c_str())
 **  if possible, so as not to lose the last character of the problem name.
 */

 /*
 **  CORRECTED VERSION
 */

 /* Fills in array with problem name  */
 COINLIBAPI void COINLINKAGE
 Clp_problemName(Clp_Simplex * model, int maxNumberCharacters, char *
 array)
 {
   std::string name = model->model_->problemName();
   maxNumberCharacters =
 CoinMin(maxNumberCharacters,1+(int)strlen(name.c_str()));
   strncpy(array,name.c_str(),maxNumberCharacters-1);
   array[maxNumberCharacters-1]='\0';
 }

-- 
Ticket URL: <https://projects.coin-or.org/Clp/ticket/44>
COIN-OR Linear Programming Solver <http://projects.coin-or.org/Clp>
A linear programming solver.



More information about the Clp-tickets mailing list