COIN-OR::LEMON - Graph Library

Ticket #213: ba124394367a.patch

File ba124394367a.patch, 1.9 KB (added by Balazs Dezso, 10 years ago)
  • lemon/glpk.cc

    # HG changeset patch
    # User Balazs Dezso <deba@inf.elte.hu>
    # Date 1235429069 -3600
    # Node ID ba124394367a55cc36b851a808f3f3218abf8367
    # Parent  0fec6a017eaddac797518d40c102144176c47fad
    Automatic GLPK env deallocation (#213)
    
    diff -r 0fec6a017ead -r ba124394367a lemon/glpk.cc
    a b  
    526526    glp_free_env();
    527527  }
    528528
     529  GlpkBase::FreeEnvHelper GlpkBase::freeEnvHelper;
     530
    529531  // GlpkLp members
    530532
    531533  GlpkLp::GlpkLp()
  • lemon/glpk.h

    diff -r 0fec6a017ead -r ba124394367a lemon/glpk.h
    a b  
    100100
    101101    virtual void _clear();
    102102
     103  private:
     104
     105    static void freeEnv();
     106
     107    struct FreeEnvHelper {
     108      ~FreeEnvHelper() {
     109        freeEnv();
     110      }
     111    };
     112   
     113    static FreeEnvHelper freeEnvHelper;
     114   
    103115  public:
    104116
    105     /// \brief Deallocates the globally allocated memory of GLPK.
    106 
    107     /// Deallocates the globally allocated memory of GLPK.  \note
    108     /// Usually, it do not have to be called, because the GLPK use
    109     /// only a small amount of global memory, and it is deallocated
    110     /// automatically at the end of program.
    111     static void freeEnv();
    112 
    113117    ///Pointer to the underlying GLPK data structure.
    114118    LPX *lpx() {return lp;}
    115119    ///Const pointer to the underlying GLPK data structure.
  • test/lp_test.cc

    diff -r 0fec6a017ead -r ba124394367a test/lp_test.cc
    a b  
    366366    lpTest(lp_glpk1);
    367367    aTest(lp_glpk2);
    368368  }
    369   GlpkLp::freeEnv();
    370369#endif
    371370
    372371#ifdef HAVE_CPLEX
  • test/mip_test.cc

    diff -r 0fec6a017ead -r ba124394367a test/mip_test.cc
    a b  
    115115    GlpkMip mip1;
    116116    aTest(mip1);
    117117  }
    118   GlpkLp::freeEnv();
    119118#endif
    120119
    121120#ifdef HAVE_CPLEX