Removed null checks before calls to delete and free (#5049)

This commit is contained in:
Roy Stewart 2021-02-13 13:06:26 -05:00 committed by GitHub
parent 92abbc42df
commit 08b3285722
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 20 additions and 36 deletions

View File

@ -32,7 +32,7 @@ public:
/// Destructor to take care of the owned default value.
~Option() {
if (_default != nullptr) delete _default;
delete _default;
_default = nullptr;
}

View File

@ -29,14 +29,11 @@ void
stl_invalidate_shared_vertices(stl_file *stl) {
if (stl->error) return;
if (stl->v_indices != NULL) {
free(stl->v_indices);
stl->v_indices = NULL;
}
if (stl->v_shared != NULL) {
free(stl->v_shared);
stl->v_shared = NULL;
}
}
void

View File

@ -437,13 +437,9 @@ void
stl_close(stl_file *stl) {
if (stl->error) return;
if(stl->neighbors_start != NULL)
free(stl->neighbors_start);
if(stl->facet_start != NULL)
free(stl->facet_start);
if(stl->v_indices != NULL)
free(stl->v_indices);
if(stl->v_shared != NULL)
free(stl->v_shared);
}

View File

@ -207,7 +207,6 @@ ConfigOptionDef::ConfigOptionDef(const ConfigOptionDef &other)
ConfigOptionDef::~ConfigOptionDef()
{
if (this->default_value != nullptr)
delete this->default_value;
}
@ -711,7 +710,7 @@ DynamicConfig::swap(DynamicConfig &other)
DynamicConfig::~DynamicConfig () {
for (t_options_map::iterator it = this->options.begin(); it != this->options.end(); ++it) {
ConfigOption* opt = it->second;
if (opt != NULL) delete opt;
delete opt;
}
}

View File

@ -16,17 +16,14 @@ AvoidCrossingPerimeters::AvoidCrossingPerimeters()
AvoidCrossingPerimeters::~AvoidCrossingPerimeters()
{
if (this->_external_mp != NULL)
delete this->_external_mp;
if (this->_layer_mp != NULL)
delete this->_layer_mp;
}
void
AvoidCrossingPerimeters::init_external_mp(const ExPolygons &islands)
{
if (this->_external_mp != NULL)
delete this->_external_mp;
this->_external_mp = new MotionPlanner(islands);
@ -35,7 +32,6 @@ AvoidCrossingPerimeters::init_external_mp(const ExPolygons &islands)
void
AvoidCrossingPerimeters::init_layer_mp(const ExPolygons &islands)
{
if (this->_layer_mp != NULL)
delete this->_layer_mp;
this->_layer_mp = new MotionPlanner(islands);

View File

@ -145,9 +145,7 @@ Model::add_material(t_model_material_id material_id, const ModelMaterial &other)
{
// delete existing material if any
ModelMaterial* material = this->get_material(material_id);
if (material != NULL) {
delete material;
}
// set new material
material = new ModelMaterial(this, other);

View File

@ -1650,7 +1650,7 @@ TriangleMeshSlicer<A>::TriangleMeshSlicer(TriangleMesh* _mesh) : mesh(_mesh), v_
template <Axis A>
TriangleMeshSlicer<A>::~TriangleMeshSlicer()
{
if (this->v_scaled_shared != NULL) free(this->v_scaled_shared);
free(this->v_scaled_shared);
}
template class TriangleMeshSlicer<X>;

View File

@ -162,10 +162,8 @@ class Filler
public:
Filler() : fill(NULL) {};
~Filler() {
if (fill != NULL) {
delete fill;
fill = NULL;
}
};
Fill* fill;
};