mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 05:15:57 +08:00
Removed null checks before calls to delete and free (#5049)
This commit is contained in:
parent
92abbc42df
commit
08b3285722
@ -32,7 +32,7 @@ public:
|
||||
|
||||
/// Destructor to take care of the owned default value.
|
||||
~Option() {
|
||||
if (_default != nullptr) delete _default;
|
||||
delete _default;
|
||||
_default = nullptr;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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>;
|
||||
|
@ -162,10 +162,8 @@ class Filler
|
||||
public:
|
||||
Filler() : fill(NULL) {};
|
||||
~Filler() {
|
||||
if (fill != NULL) {
|
||||
delete fill;
|
||||
fill = NULL;
|
||||
}
|
||||
};
|
||||
Fill* fill;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user