mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
spa: add macro to simplify array iterations some more
uint32_t i; for (i = 0; i < SPA_N_ELEMENTS(some_array); i++) .. stuff with some_array[i].foo ... becomes: SPA_FOR_EACH_ELEMENT_VAR(some_array, p) .. stuff with p->foo ..
This commit is contained in:
parent
365ebcda9b
commit
d22feab92a
21 changed files with 113 additions and 150 deletions
|
|
@ -358,16 +358,13 @@ pwtest_spa_plugin_new(void)
|
|||
void
|
||||
pwtest_spa_plugin_destroy(struct pwtest_spa_plugin *plugin)
|
||||
{
|
||||
void **dll;
|
||||
struct spa_handle **hnd;
|
||||
|
||||
SPA_FOR_EACH_ELEMENT(plugin->handles, hnd) {
|
||||
SPA_FOR_EACH_ELEMENT_VAR(plugin->handles, hnd) {
|
||||
if (*hnd) {
|
||||
spa_handle_clear(*hnd);
|
||||
free(*hnd);
|
||||
}
|
||||
}
|
||||
SPA_FOR_EACH_ELEMENT(plugin->dlls, dll) {
|
||||
SPA_FOR_EACH_ELEMENT_VAR(plugin->dlls, dll) {
|
||||
if (*dll)
|
||||
dlclose(*dll);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,9 +184,8 @@ PWTEST(utils_macros)
|
|||
|
||||
#define check_traversal(array_) \
|
||||
{ \
|
||||
__typeof__(array_[0]) *it; \
|
||||
int count = 0; \
|
||||
SPA_FOR_EACH_ELEMENT(array_, it) \
|
||||
SPA_FOR_EACH_ELEMENT_VAR(array_, it) \
|
||||
*it = count++; \
|
||||
for (size_t i = 0; i < SPA_N_ELEMENTS(array_); i++) \
|
||||
pwtest_int_eq(array_[i], i); \
|
||||
|
|
|
|||
|
|
@ -172,9 +172,7 @@ static void test__pw_split_walk(void)
|
|||
},
|
||||
};
|
||||
|
||||
const struct test_case *tc;
|
||||
|
||||
SPA_FOR_EACH_ELEMENT(test_cases, tc) {
|
||||
SPA_FOR_EACH_ELEMENT_VAR(test_cases, tc) {
|
||||
const char *str = tc->input, *s;
|
||||
const char *state = NULL;
|
||||
size_t j = 0, len;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue