diff options
author | David Robillard <d@drobilla.net> | 2012-07-17 22:34:21 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-07-17 22:34:21 +0000 |
commit | d005ad52a363749d32b3864a2b81de30bf0df248 (patch) | |
tree | dd6fb705e0087dd327c349206996622e6587e93c | |
parent | 683dd3f900202df16de1721ebabac82be3a8c37e (diff) | |
download | raul-d005ad52a363749d32b3864a2b81de30bf0df248.tar.gz raul-d005ad52a363749d32b3864a2b81de30bf0df248.tar.bz2 raul-d005ad52a363749d32b3864a2b81de30bf0df248.zip |
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
-rw-r--r-- | raul/Atom.hpp | 10 |
1 files 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); } } |