Changeset 1118 for trunk/yat/utility


Ignore:
Timestamp:
Feb 21, 2008, 11:08:23 PM (14 years ago)
Author:
Peter
Message:

fixing memory bug in VectorView? - fixes #305

Location:
trunk/yat/utility
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/VectorMutable.cc

    r1038 r1118  
    177177  VectorMutable::operator proxy()
    178178  {
     179    assert(vec_==const_vec_);
    179180    proxy p;
    180181    p.vec_ = vec_;
    181182    vec_ = NULL; // proxy takes ownership and delivers to its receiver
     183    const_vec_ = NULL;
    182184    return p;
    183185  }
  • trunk/yat/utility/VectorMutable.h

    r1046 r1118  
    220220       VectorView from a temporary VectorView returned from a
    221221       function. Instead this proxy class is created from the
    222        temporary object and then a VectorView can be created from thsi
     222       temporary object and then a VectorView can be created from this
    223223       proxy.
    224224
     
    231231
    232232  private:
    233     // copy assignment no allowed
     233    // copy assignment not allowed
    234234    const VectorMutable& operator=(const VectorMutable&);
    235235  public:
  • trunk/yat/utility/VectorView.cc

    r1027 r1118  
    6363    : VectorMutable()
    6464  {
    65     view_ = new gsl_vector_view(gsl_vector_subvector(other.gsl_vector_p(),
    66                                                      0,other.size()));
    67     const_vec_ = vec_ = &(view_->vector);
     65    copy(other.gsl_vector_p());
    6866  }
    6967
     
    9088
    9189  VectorView::VectorView(proxy p)
    92     : VectorMutable(p.vec_), view_(NULL)
     90    : VectorMutable(), view_(NULL)
    9391  {
     92    copy(p.vec_);
    9493  }
    9594
     
    111110    return *this;
    112111  }
     112
     113
     114  void VectorView::copy(gsl_vector* other )
     115  {
     116    view_ = new gsl_vector_view(gsl_vector_subvector(other,0,other->size));
     117    const_vec_ = vec_ = &(view_->vector);
     118  }
    113119
    114120
  • trunk/yat/utility/VectorView.h

    r1046 r1118  
    185185  private:
    186186    const VectorView& assign(const VectorBase& other);
     187    void copy(gsl_vector*);
    187188    void delete_allocated_memory(void);
    188189
Note: See TracChangeset for help on using the changeset viewer.