mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 00:26:00 +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.
|
/// Destructor to take care of the owned default value.
|
||||||
~Option() {
|
~Option() {
|
||||||
if (_default != nullptr) delete _default;
|
delete _default;
|
||||||
_default = nullptr;
|
_default = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,15 +29,12 @@ void
|
|||||||
stl_invalidate_shared_vertices(stl_file *stl) {
|
stl_invalidate_shared_vertices(stl_file *stl) {
|
||||||
if (stl->error) return;
|
if (stl->error) return;
|
||||||
|
|
||||||
if (stl->v_indices != NULL) {
|
|
||||||
free(stl->v_indices);
|
free(stl->v_indices);
|
||||||
stl->v_indices = NULL;
|
stl->v_indices = NULL;
|
||||||
}
|
|
||||||
if (stl->v_shared != NULL) {
|
|
||||||
free(stl->v_shared);
|
free(stl->v_shared);
|
||||||
stl->v_shared = NULL;
|
stl->v_shared = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
stl_generate_shared_vertices(stl_file *stl) {
|
stl_generate_shared_vertices(stl_file *stl) {
|
||||||
|
@ -437,13 +437,9 @@ void
|
|||||||
stl_close(stl_file *stl) {
|
stl_close(stl_file *stl) {
|
||||||
if (stl->error) return;
|
if (stl->error) return;
|
||||||
|
|
||||||
if(stl->neighbors_start != NULL)
|
|
||||||
free(stl->neighbors_start);
|
free(stl->neighbors_start);
|
||||||
if(stl->facet_start != NULL)
|
|
||||||
free(stl->facet_start);
|
free(stl->facet_start);
|
||||||
if(stl->v_indices != NULL)
|
|
||||||
free(stl->v_indices);
|
free(stl->v_indices);
|
||||||
if(stl->v_shared != NULL)
|
|
||||||
free(stl->v_shared);
|
free(stl->v_shared);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +207,6 @@ ConfigOptionDef::ConfigOptionDef(const ConfigOptionDef &other)
|
|||||||
|
|
||||||
ConfigOptionDef::~ConfigOptionDef()
|
ConfigOptionDef::~ConfigOptionDef()
|
||||||
{
|
{
|
||||||
if (this->default_value != nullptr)
|
|
||||||
delete this->default_value;
|
delete this->default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -711,7 +710,7 @@ DynamicConfig::swap(DynamicConfig &other)
|
|||||||
DynamicConfig::~DynamicConfig () {
|
DynamicConfig::~DynamicConfig () {
|
||||||
for (t_options_map::iterator it = this->options.begin(); it != this->options.end(); ++it) {
|
for (t_options_map::iterator it = this->options.begin(); it != this->options.end(); ++it) {
|
||||||
ConfigOption* opt = it->second;
|
ConfigOption* opt = it->second;
|
||||||
if (opt != NULL) delete opt;
|
delete opt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,17 +16,14 @@ AvoidCrossingPerimeters::AvoidCrossingPerimeters()
|
|||||||
|
|
||||||
AvoidCrossingPerimeters::~AvoidCrossingPerimeters()
|
AvoidCrossingPerimeters::~AvoidCrossingPerimeters()
|
||||||
{
|
{
|
||||||
if (this->_external_mp != NULL)
|
|
||||||
delete this->_external_mp;
|
delete this->_external_mp;
|
||||||
|
|
||||||
if (this->_layer_mp != NULL)
|
|
||||||
delete this->_layer_mp;
|
delete this->_layer_mp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AvoidCrossingPerimeters::init_external_mp(const ExPolygons &islands)
|
AvoidCrossingPerimeters::init_external_mp(const ExPolygons &islands)
|
||||||
{
|
{
|
||||||
if (this->_external_mp != NULL)
|
|
||||||
delete this->_external_mp;
|
delete this->_external_mp;
|
||||||
|
|
||||||
this->_external_mp = new MotionPlanner(islands);
|
this->_external_mp = new MotionPlanner(islands);
|
||||||
@ -35,7 +32,6 @@ AvoidCrossingPerimeters::init_external_mp(const ExPolygons &islands)
|
|||||||
void
|
void
|
||||||
AvoidCrossingPerimeters::init_layer_mp(const ExPolygons &islands)
|
AvoidCrossingPerimeters::init_layer_mp(const ExPolygons &islands)
|
||||||
{
|
{
|
||||||
if (this->_layer_mp != NULL)
|
|
||||||
delete this->_layer_mp;
|
delete this->_layer_mp;
|
||||||
|
|
||||||
this->_layer_mp = new MotionPlanner(islands);
|
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
|
// delete existing material if any
|
||||||
ModelMaterial* material = this->get_material(material_id);
|
ModelMaterial* material = this->get_material(material_id);
|
||||||
if (material != NULL) {
|
|
||||||
delete material;
|
delete material;
|
||||||
}
|
|
||||||
|
|
||||||
// set new material
|
// set new material
|
||||||
material = new ModelMaterial(this, other);
|
material = new ModelMaterial(this, other);
|
||||||
|
@ -1650,7 +1650,7 @@ TriangleMeshSlicer<A>::TriangleMeshSlicer(TriangleMesh* _mesh) : mesh(_mesh), v_
|
|||||||
template <Axis A>
|
template <Axis A>
|
||||||
TriangleMeshSlicer<A>::~TriangleMeshSlicer()
|
TriangleMeshSlicer<A>::~TriangleMeshSlicer()
|
||||||
{
|
{
|
||||||
if (this->v_scaled_shared != NULL) free(this->v_scaled_shared);
|
free(this->v_scaled_shared);
|
||||||
}
|
}
|
||||||
|
|
||||||
template class TriangleMeshSlicer<X>;
|
template class TriangleMeshSlicer<X>;
|
||||||
|
@ -162,10 +162,8 @@ class Filler
|
|||||||
public:
|
public:
|
||||||
Filler() : fill(NULL) {};
|
Filler() : fill(NULL) {};
|
||||||
~Filler() {
|
~Filler() {
|
||||||
if (fill != NULL) {
|
|
||||||
delete fill;
|
delete fill;
|
||||||
fill = NULL;
|
fill = NULL;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Fill* fill;
|
Fill* fill;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user