[Cgl-tickets] Re: [COIN-OR Cut Generator Library] #16: CglTwomir probname_; inconsistent usage, possible trivial memory leak

COIN-OR Cut Generator Library coin-trac at coin-or.org
Thu May 31 18:13:11 EDT 2007


#16: CglTwomir probname_; inconsistent usage, possible trivial memory leak
------------------------+---------------------------------------------------
  Reporter:  lou        |       Owner:  somebody
      Type:  defect     |      Status:  new     
  Priority:  minor      |   Milestone:          
 Component:  CglTwomir  |     Version:  trunk   
Resolution:             |    Keywords:          
------------------------+---------------------------------------------------
Comment (by lou):

 Well, trac isn't going to let me attach the files. So ... in
 CglTwomir.hpp, change the declaration of probname_ to read
 {{{
 /// Problem name
 mutable std::string probname_
 }}}

 Here's a diff of CglTwomir.cpp.

 {{{
 --- src/CglTwomir/CglTwomir.cpp (revision 451)
 +++ src/CglTwomir/CglTwomir.cpp (working copy)
 @@ -34,10 +34,14 @@
  #define  a_max  data->cparams.a_max
  #define  max_elements  data->cparams.max_elements

 -#define talk false // true
 +#ifdef CGL_DEBUG
 +// Declarations and defines for debug build.

 +#define talk true

 -const OsiSolverInterface * six;
 +namespace {
 +  const OsiSolverInterface *six ;
 +}

  void write_cut( DGG_constraint_t *cut){
 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
         printf("2mir_test: cut:
 !!!!!!!!!!!!!!!!!!!!!!!***********************************\n");
 @@ -65,16 +69,24 @@
      }
  }

 +#else  // CGL_DEBUG

 +#define talk false
 +
 +#endif // CGL_DEBUG
 +
 +
  //-------------------------------------------------------------------
  // Generate  cuts
  //-------------------------------------------------------------------
  void CglTwomir::generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
                              const CglTreeInfo info ) const
  {
 -
 +# ifdef CGL_DEBUG
    //!!!!!!!!!!!!!!!!!!
    six = &si;
 +# endif
 +
    // Temp - check if free variables
    {
      const double *colUpper = si.getColUpper();
 @@ -91,6 +103,8 @@
        return;
      }
    }
 +
 +  si.getStrParam(OsiProbName,probname_) ;

    DGG_list_t cut_list;
    DGG_list_init (&cut_list);
 @@ -116,7 +130,7 @@
                                  info.formulation_rows );

  #ifdef CGL_DEBUG
 -  const OsiRowCutDebugger debugg(si, probname_);// =
 si.getRowCutDebugger();
 +  const OsiRowCutDebugger debugg(si,probname_.c_str()) ;
    const OsiRowCutDebugger *debugger = &debugg;
    if (debugger&&!debugger->onOptimalPath(si))
      debugger = NULL;
 @@ -158,7 +172,7 @@
  //-------------------------------------------------------------------
  CglTwomir::CglTwomir () :
    CglCutGenerator(),
 -  probname_(NULL),
 +  probname_(),
    do_mir_(true), do_2mir_(true), do_tab_(true), do_form_(true),
    t_min_(1), t_max_(1), q_min_(1), q_max_(1),
 a_max_(2),max_elements_(50000),
    form_nrows_(0) {}
 @@ -180,10 +194,7 @@
    max_elements_(source.max_elements_),
    form_nrows_(source.form_nrows_)
  {
 -  if (source.probname_)
 -    probname_ = strdup(source.probname_);
 -  else
 -    probname_=NULL;
 +  probname_ = source.probname_ ;
  }
 }}}

-- 
Ticket URL: <https://projects.coin-or.org:8888/Cgl/ticket/16#comment:1>
COIN-OR Cut Generator Library <http://projects.coin-or.org/Cgl>
A library of mixed-integer programming cutting plane generators.



More information about the Cgl-tickets mailing list