Ignore:
Timestamp:
Feb 23, 2008, 9:40:35 PM (15 years ago)
Author:
Peter
Message:

using SmartPtr? in KernelLookup? rather than doing the ref count myself

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/classifier/KernelLookup.cc

    r1132 r1133  
    3838
    3939  KernelLookup::KernelLookup(const Kernel& kernel, const bool own)
    40     : kernel_(&kernel)
    41   {
    42     if (own)
    43       ref_count_ = new u_int(1);
    44     else
    45       ref_count_ = NULL;
     40    : kernel_(utility::SmartPtr<const Kernel>(&kernel, own))
     41  {
    4642    column_index_.reserve(kernel.size());
    4743    for(size_t i=0; i<kernel.size(); i++)
     
    5551                             const std::vector<size_t>& column,
    5652                             const bool owner)
    57     : column_index_(column), kernel_(&kernel), ref_count_(NULL),
     53    : column_index_(column),
     54      kernel_(utility::SmartPtr<const Kernel>(&kernel, owner)),
    5855      row_index_(row)
    5956  {
     
    8481      column_index_.push_back(other.column_index_[column[i]]);
    8582    }
    86     ref_count_=other.ref_count_;
    87     if (ref_count_)
    88       ++(*ref_count_);
    8983  }
    9084 
     
    10195           *(max_element(column_index_.begin(), column_index_.end()))<
    10296           kernel_->size());
    103     ref_count_=other.ref_count_;
    104     if (ref_count_)
    105       ++(*ref_count_);
    10697  }
    10798 
     
    138129           *(max_element(column_index_.begin(), column_index_.end()))<
    139130           kernel_->size());
    140     ref_count_=other.ref_count_;
    141     if (ref_count_)
    142       ++(*ref_count_);
    143131  }
    144132 
     
    146134  KernelLookup::~KernelLookup(void)
    147135  {
    148     if (ref_count_)
    149       if (!--(*ref_count_))
    150         delete kernel_;
    151136  }
    152137
Note: See TracChangeset for help on using the changeset viewer.