libobs: Add obs_data_array_push_back_array

Allows easily/safely appending all the values of one data array to
another.
This commit is contained in:
jp9000 2018-07-15 17:05:30 -07:00
parent a8517f3698
commit 2329c6f6ea
2 changed files with 15 additions and 0 deletions

View File

@ -1319,6 +1319,19 @@ void obs_data_array_insert(obs_data_array_t *array, size_t idx, obs_data_t *obj)
da_insert(array->objects, idx, &obj);
}
void obs_data_array_push_back_array(obs_data_array_t *array,
obs_data_array_t *array2)
{
if (!array || !array2)
return;
for (size_t i = 0; i < array2->objects.num; i++) {
obs_data_t *obj = array2->objects.array[i];
obs_data_addref(obj);
}
da_push_back_da(array->objects, array2->objects);
}
void obs_data_array_erase(obs_data_array_t *array, size_t idx)
{
if (array) {

View File

@ -159,6 +159,8 @@ EXPORT obs_data_t *obs_data_array_item(obs_data_array_t *array, size_t idx);
EXPORT size_t obs_data_array_push_back(obs_data_array_t *array, obs_data_t *obj);
EXPORT void obs_data_array_insert(obs_data_array_t *array, size_t idx,
obs_data_t *obj);
EXPORT void obs_data_array_push_back_array(obs_data_array_t *array,
obs_data_array_t *array2);
EXPORT void obs_data_array_erase(obs_data_array_t *array, size_t idx);
/* ------------------------------------------------------------------------- */