mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
dynamic: add _continue
The continue functions takes a builder as the argument and makes a new builder that starts from the old builder memory. If the old builder was dynamic, the new one will also be dynamic. Because it's a separate builder, the memory of the old builder will not be reallocated when extended. This makes it possible to freely read the memory from the old builder while we construct the result in a new builder without having to worry about reallocating the memory of the old builder. When the new object is completed, it can then be copied into the old builder.
This commit is contained in:
parent
336a5d1ded
commit
205ee5b6b0
1 changed files with 11 additions and 1 deletions
|
|
@ -53,11 +53,21 @@ SPA_API_POD_DYNAMIC void spa_pod_dynamic_builder_init(struct spa_pod_dynamic_bui
|
|||
.overflow = spa_pod_dynamic_builder_overflow
|
||||
};
|
||||
builder->b = SPA_POD_BUILDER_INIT(data, size);
|
||||
spa_pod_builder_set_callbacks(&builder->b, &spa_pod_dynamic_builder_callbacks, builder);
|
||||
if (extend > 0)
|
||||
spa_pod_builder_set_callbacks(&builder->b, &spa_pod_dynamic_builder_callbacks, builder);
|
||||
builder->extend = extend;
|
||||
builder->data = data;
|
||||
}
|
||||
|
||||
SPA_API_POD_DYNAMIC void spa_pod_dynamic_builder_continue(struct spa_pod_dynamic_builder *builder,
|
||||
struct spa_pod_builder *b)
|
||||
{
|
||||
uint32_t remain = b->state.offset >= b->size ? 0 : b->size - b->state.offset;
|
||||
spa_pod_dynamic_builder_init(builder,
|
||||
remain ? SPA_PTROFF(b->data, b->state.offset, void) : NULL,
|
||||
remain, b->callbacks.funcs == NULL ? 0 : 4096);
|
||||
}
|
||||
|
||||
SPA_API_POD_DYNAMIC void spa_pod_dynamic_builder_clean(struct spa_pod_dynamic_builder *builder)
|
||||
{
|
||||
if (builder->data != builder->b.data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue