summaryrefslogtreecommitdiffstats
path: root/raul
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-07-17 22:34:21 +0000
committerDavid Robillard <d@drobilla.net>2012-07-17 22:34:21 +0000
commitd005ad52a363749d32b3864a2b81de30bf0df248 (patch)
treedd6fb705e0087dd327c349206996622e6587e93c /raul
parent683dd3f900202df16de1721ebabac82be3a8c37e (diff)
downloadraul-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
Diffstat (limited to 'raul')
-rw-r--r--raul/Atom.hpp10
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);
}
}