diff options
| author | David Robillard <d@drobilla.net> | 2011-11-09 01:08:14 +0000 | 
|---|---|---|
| committer | David Robillard <d@drobilla.net> | 2011-11-09 01:08:14 +0000 | 
| commit | 7b90f2dac53b7cd17fb9499c4cedf2b301d90129 (patch) | |
| tree | 7e7c6a42dede9a090de04093f289ac4056e0610b /ext/atom.lv2/atom-buffer.h | |
| parent | 672ba53efd1b6a39748b919f015761a7ef270d66 (diff) | |
| download | lv2-7b90f2dac53b7cd17fb9499c4cedf2b301d90129.tar.xz | |
Define types as complete objects, not just atom bodies.
Improve helper API.
Diffstat (limited to 'ext/atom.lv2/atom-buffer.h')
| -rw-r--r-- | ext/atom.lv2/atom-buffer.h | 21 | 
1 files changed, 7 insertions, 14 deletions
diff --git a/ext/atom.lv2/atom-buffer.h b/ext/atom.lv2/atom-buffer.h index 2ac71e3..f4b90dd 100644 --- a/ext/atom.lv2/atom-buffer.h +++ b/ext/atom.lv2/atom-buffer.h @@ -28,20 +28,10 @@  #include <stdbool.h>  #include <string.h>  #include <stdlib.h> -#include <assert.h>  #include "lv2/lv2plug.in/ns/ext/atom/atom.h"  /** -   Pad a size to 64 bits. -*/ -static inline uint32_t -lv2_atom_pad_size(uint32_t size) -{ -	return (size + 7) & (~7); -} - -/**     Initialize an existing atom buffer.     All fields of @c buf are reset, except capacity which is unmodified.  */ @@ -111,9 +101,10 @@ lv2_atom_buffer_is_valid(LV2_Atom_Buffer_Iterator i)  static inline LV2_Atom_Buffer_Iterator  lv2_atom_buffer_next(LV2_Atom_Buffer_Iterator i)  { -	assert(lv2_atom_buffer_is_valid(i)); -	const LV2_Atom_Event* const ev = (LV2_Atom_Event*)( -		i.buf->data + i.offset); +	if (!lv2_atom_buffer_is_valid(i)) { +		return i; +	} +	const LV2_Atom_Event* const ev = (LV2_Atom_Event*)(i.buf->data + i.offset);  	i.offset += lv2_atom_pad_size(sizeof(LV2_Atom_Event) + ev->body.size);  	return i;  } @@ -124,7 +115,9 @@ lv2_atom_buffer_next(LV2_Atom_Buffer_Iterator i)  static inline LV2_Atom_Event*  lv2_atom_buffer_get(LV2_Atom_Buffer_Iterator i)  { -	assert(lv2_event_is_valid(i)); +	if (!lv2_atom_buffer_is_valid(i)) { +		return NULL; +	}  	return (LV2_Atom_Event*)(i.buf->data + i.offset);  }  |