Changeset 3909


Ignore:
Timestamp:
Sep 12, 2008, 4:08:04 PM (12 years ago)
Author:
yura
Message:
  • Each array deleted only one time.
Location:
to-imperative/trunk/opents/samples
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/opents/samples/fff.tcc

    r3908 r3909  
    149149
    150150  //std::istringstream is_c_1("(A)");
    151   _c_1.init(1).concat(_c_0.subexpr(0,1));
     151  _c_1 = _c_0.subexpr(0,1);
    152152
    153153  //std::istringstream is_c_2("(B)");
    154   _c_2.init(2).concat(_c_0.subexpr(1,2));
     154  _c_2 = _c_0.subexpr(0,2);
    155155  return 0;
    156156}
  • to-imperative/trunk/opents/samples/trefal.hh

    r3907 r3909  
    6363    Term* terms;
    6464    size_t size;
    65 
    66     GExpr () : terms(0), size(0) {}
     65    bool need_delete;
     66
     67    GExpr () : terms(0), size(0), need_delete(false) {}
    6768
    6869    inline GExpr (TExpr& _e);
    6970
    70     GExpr (int size) : terms(new Term[size]), size(0) {}
     71    GExpr (int size) : terms(new Term[size]), size(0), need_delete(true) {}
    7172
    7273    GExpr& init (int size) {
     
    7475            throw 0;
    7576        terms = new Term[size];
     77        need_delete = true;
    7678        return *this;
    7779    }
     
    8284        terms = e.terms;
    8385        size = e.size;
     86        need_delete = e.need_delete;
    8487        return *this;
    8588    }
     
    122125
    123126    void clear () {
    124         delete[] terms;
     127        if (need_delete)
     128            delete[] terms;
    125129    }
    126130};
     
    384388// =================================== GExpr ===================================
    385389
    386 inline GExpr::GExpr (TExpr& _e) : terms((Expr&)_e), size(((Expr&)_e).get_len()) {}
     390inline GExpr::GExpr (TExpr& _e) : terms((Expr&)_e), size(((Expr&)_e).get_len()), need_delete(false) {}
    387391
    388392GExpr& GExpr::add (const GExpr& e) {
Note: See TracChangeset for help on using the changeset viewer.