summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/value.cc4
-rw-r--r--src/value.h28
2 files changed, 18 insertions, 14 deletions
diff --git a/src/value.cc b/src/value.cc
index a7d3c7e5..90067bba 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -119,7 +119,7 @@ void value_t::set_type(type_t new_type)
if (! storage || storage->refc > 1)
storage = new storage_t;
else
- storage->data = false; // destruct all other types
+ storage->destroy();
storage->type = new_type;
assert(is_type(new_type));
}
@@ -911,7 +911,7 @@ void value_t::in_place_cast(type_t cast_type)
if (amt.is_null())
set_balance(balance_t());
else
- set_balance(as_amount()); // creates temporary
+ set_balance(as_amount());
return;
case STRING:
if (amt.is_null())
diff --git a/src/value.h b/src/value.h
index 3a052fb2..5fb78cb4 100644
--- a/src/value.h
+++ b/src/value.h
@@ -166,19 +166,8 @@ private:
*/
~storage_t() {
TRACE_DTOR(value_t::storage_t);
- DEBUG("value.storage.refcount", "Destroying " << this);
assert(refc == 0);
-
- switch (type) {
- case BALANCE:
- checked_delete(boost::get<balance_t *>(data));
- break;
- case SEQUENCE:
- checked_delete(boost::get<sequence_t *>(data));
- break;
- default:
- break;
- }
+ destroy();
}
private:
@@ -218,6 +207,21 @@ private:
friend inline void intrusive_ptr_release(value_t::storage_t * storage) {
storage->release();
}
+
+ void destroy() {
+ DEBUG("value.storage.refcount", "Destroying " << this);
+ switch (type) {
+ case BALANCE:
+ checked_delete(boost::get<balance_t *>(data));
+ break;
+ case SEQUENCE:
+ checked_delete(boost::get<sequence_t *>(data));
+ break;
+ default:
+ break;
+ }
+ type = VOID;
+ }
};
/**