Skip to content

Commit

Permalink
Removed unnecessary null pointer checks
Browse files Browse the repository at this point in the history
  • Loading branch information
RainerKuemmerle committed Mar 25, 2016
1 parent 3539047 commit 9fb9e29
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 46 deletions.
54 changes: 18 additions & 36 deletions g2o/core/block_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,42 +91,24 @@ void BlockSolver<Traits>::resize(int* blockPoseIndices, int numPoseBlocks,
template <typename Traits>
void BlockSolver<Traits>::deallocate()
{
if (_Hpp){
delete _Hpp;
_Hpp=0;
}
if (_Hll){
delete _Hll;
_Hll=0;
}
if (_Hpl){
delete _Hpl;
_Hpl = 0;
}
if (_Hschur){
delete _Hschur;
_Hschur=0;
}
if (_DInvSchur){
delete _DInvSchur;
_DInvSchur=0;
}
if (_coefficients) {
delete[] _coefficients;
_coefficients = 0;
}
if (_bschur) {
delete[] _bschur;
_bschur = 0;
}
if (_HplCCS) {
delete _HplCCS;
_HplCCS = 0;
}
if (_HschurTransposedCCS) {
delete _HschurTransposedCCS;
_HschurTransposedCCS = 0;
}
delete _Hpp;
_Hpp=0;
delete _Hll;
_Hll=0;
delete _Hpl;
_Hpl = 0;
delete _Hschur;
_Hschur=0;
delete _DInvSchur;
_DInvSchur=0;
delete[] _coefficients;
_coefficients = 0;
delete[] _bschur;
_bschur = 0;
delete _HplCCS;
_HplCCS = 0;
delete _HschurTransposedCCS;
_HschurTransposedCCS = 0;
}

template <typename Traits>
Expand Down
3 changes: 1 addition & 2 deletions g2o/core/hyper_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ namespace g2o {
}

HyperGraph::Data::~Data() {
if(_next)
delete _next;
delete _next;
}

HyperGraph::Vertex::Vertex(int id) : _id(id)
Expand Down
6 changes: 2 additions & 4 deletions g2o/core/optimizable_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,8 @@ namespace g2o {

OptimizableGraph::Vertex::~Vertex()
{
if (_cacheContainer)
delete (_cacheContainer);
if (_userData)
delete _userData;
delete _cacheContainer;
delete _userData;
}

OptimizableGraph::Vertex* OptimizableGraph::Vertex::clone() const
Expand Down
8 changes: 4 additions & 4 deletions g2o/stuff/sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ namespace g2o {
template <class SampleType, class CovarianceType>
class GaussianSampler {
public:
GaussianSampler(bool hasGenerator=true){
_generator = 0;
GaussianSampler(bool hasGenerator=true) :
_generator(0)
{
if (hasGenerator){
_generator = new std::mt19937;
}
}
~GaussianSampler() {
if (_generator)
delete _generator;
delete _generator;
}
void setDistribution(const CovarianceType& cov){
Eigen::LLT<CovarianceType> cholDecomp;
Expand Down

0 comments on commit 9fb9e29

Please sign in to comment.