From d005ad52a363749d32b3864a2b81de30bf0df248 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 17 Jul 2012 22:34:21 +0000 Subject: Allow Atom construction from NULL buffer, allocate but don't initialize. This is useful when reading Atoms from a RingBuffer. git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4544 a436a847-0d15-0410-975c-d299462d15a1 --- raul/Atom.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/raul/Atom.hpp b/raul/Atom.hpp index 2ceed89..149f78f 100644 --- a/raul/Atom.hpp +++ b/raul/Atom.hpp @@ -106,6 +106,10 @@ public: return is_reference() ? _val._blob : &_val; } + inline void* get_body() { + return is_reference() ? _val._blob : &_val; + } + inline int32_t get_int32() const { return _val._int; } inline float get_float() const { return _val._float; } inline bool get_bool() const { return _val._bool; } @@ -121,9 +125,9 @@ private: { if (is_reference()) { _val._blob = malloc(s); - memcpy(_val._blob, v, s); - } else { - memcpy(&_val, v, s); + } + if (v) { + memcpy(get_body(), v, s); } } -- cgit v1.2.1