From 0752556bde5659a933744658cdf63509000a5080 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 6 Dec 2016 11:03:35 -0500 Subject: Fix some real-time safety issues --- ingen/Atom.hpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'ingen/Atom.hpp') diff --git a/ingen/Atom.hpp b/ingen/Atom.hpp index e26462a5..4015e59e 100644 --- a/ingen/Atom.hpp +++ b/ingen/Atom.hpp @@ -72,7 +72,7 @@ public: _body.ptr = (LV2_Atom*)malloc(sizeof(LV2_Atom) + _atom.size); memcpy(_body.ptr, copy._body.ptr, sizeof(LV2_Atom) + _atom.size); } else { - memcpy(&_body.val, ©._body.val, sizeof(_body.val)); + _body.val = copy._body.val; } } @@ -86,7 +86,7 @@ public: _body.ptr = (LV2_Atom*)malloc(sizeof(LV2_Atom) + _atom.size); memcpy(_body.ptr, other._body.ptr, sizeof(LV2_Atom) + _atom.size); } else { - memcpy(&_body.val, &other._body.val, sizeof(_body.val)); + _body.val = other._body.val; } return *this; } @@ -116,6 +116,20 @@ public: return type() < other.type(); } + /** Like assignment, but only works for value atoms (not references). + * Always real-time safe. + * @return true iff set succeeded. + */ + inline bool set_rt(const Atom& other) { + if (is_reference()) { + return false; + } else { + _atom = other._atom; + _body.val = other._body.val; + return true; + } + } + inline uint32_t size() const { return _atom.size; } inline LV2_URID type() const { return _atom.type; } inline bool is_valid() const { return _atom.type; } -- cgit v1.2.1