builder: add _rewind method

Add a rewind method to undoes the data of a frame.
Add unit test for overflow and rewind
This commit is contained in:
Wim Taymans 2019-06-26 12:17:01 +02:00
parent 15b6c7ef7e
commit 350e8051a7
2 changed files with 76 additions and 0 deletions

View file

@ -173,6 +173,15 @@ static inline void *spa_pod_builder_pop(struct spa_pod_builder *builder, struct
return pod;
}
static inline void spa_pod_builder_rewind(struct spa_pod_builder *builder, uint32_t offset)
{
struct spa_pod_frame *f;
uint32_t size = builder->state.offset - offset;
builder->state.offset -= size;
for (f = builder->state.frame; f ; f = f->parent)
f->pod.size -= size;
}
static inline int
spa_pod_builder_primitive(struct spa_pod_builder *builder, const struct spa_pod *p)
{