From 8afeabfd6935fdb6b7587f6fca5f85705a0f2b36 Mon Sep 17 00:00:00 2001 From: CHatingPython Date: Wed, 10 Jun 2026 16:05:53 +0200 Subject: [PATCH] refactor(furvm): future-proofing thing ctor and dtor --- furvm/src/thing.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/furvm/src/thing.cpp b/furvm/src/thing.cpp index f13cbe6..2e6a059 100644 --- a/furvm/src/thing.cpp +++ b/furvm/src/thing.cpp @@ -37,10 +37,21 @@ thing::thing(rzecz, thing_handle id, thing_t type, const context_p& context) if (data == nullptr) throw std::runtime_error("failed to allocate data for new thing"); std::memcpy(data, &type, sizeof(type)); m_data = data + sizeof(type); - std::memset(m_data, 0, size); + + switch (m_type) { + // Primitives are zero-initialized. + default: + case thing_t::Int32: std::memset(m_data, 0, size); + } } thing::~thing() { + switch (m_type) { + // Primitives are not destructed. + default: + case thing_t::Int32: break; + } + m_context->m_deadThingData.push_back(m_data); }