Skip to content
Snippets Groups Projects
Commit 7067b7b6 authored by Florent Lamiraux's avatar Florent Lamiraux
Browse files

Do not try to delete void*, behavior is undefined.

parent 96fc928e
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,7 @@ namespace dynamicgraph { ...@@ -59,6 +59,7 @@ namespace dynamicgraph {
NB_TYPES NB_TYPES
}; };
~Value(); ~Value();
void deleteValue ();
explicit Value(const bool& value); explicit Value(const bool& value);
explicit Value(const unsigned& value); explicit Value(const unsigned& value);
explicit Value(const int& value); explicit Value(const int& value);
......
...@@ -67,7 +67,7 @@ namespace dynamicgraph { ...@@ -67,7 +67,7 @@ namespace dynamicgraph {
return value_->matrixValue(); return value_->matrixValue();
} }
Value::~Value() void Value::deleteValue ()
{ {
switch(type_) { switch(type_) {
case BOOL: case BOOL:
...@@ -98,6 +98,11 @@ namespace dynamicgraph { ...@@ -98,6 +98,11 @@ namespace dynamicgraph {
} }
} }
Value::~Value()
{
deleteValue ();
}
Value::Value(const bool& value) : type_(BOOL), value_(new bool(value)) Value::Value(const bool& value) : type_(BOOL), value_(new bool(value))
{ {
} }
...@@ -179,9 +184,9 @@ namespace dynamicgraph { ...@@ -179,9 +184,9 @@ namespace dynamicgraph {
Value Value::operator=(const Value& value) Value Value::operator=(const Value& value)
{ {
if (&value != this) { if (&value != this) {
type_ = value.type_;
if(value_ != 0x0) if(value_ != 0x0)
delete value_; deleteValue ();
type_ = value.type_;
void** ptValue = const_cast<void**>(&value_); void** ptValue = const_cast<void**>(&value_);
*ptValue = copyValue(value); *ptValue = copyValue(value);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment