mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-09-30 05:05:27 +00:00
spa: utils: use SPA_N_ELEMENTS
in for-each macros
This way the compiler is able to detect cases when a pointer is specified instead of an array. Furthermore, incompatible pointer types can also be diagnosed in `SPA_FOR_EACH_ELEMENT()`.
This commit is contained in:
parent
7c40cafa7c
commit
adc60af45b
|
@ -133,10 +133,10 @@ struct spa_fraction {
|
|||
* ```
|
||||
*/
|
||||
#define SPA_FOR_EACH_ELEMENT(arr, ptr) \
|
||||
for ((ptr) = arr; (void*)(ptr) < SPA_PTROFF(arr, sizeof(arr), void); (ptr)++)
|
||||
for ((ptr) = arr; (ptr) < (arr) + SPA_N_ELEMENTS(arr); (ptr)++)
|
||||
|
||||
#define SPA_FOR_EACH_ELEMENT_VAR(arr, var) \
|
||||
for (__typeof__((arr)[0])* var = arr; (void*)(var) < SPA_PTROFF(arr, sizeof(arr), void); (var)++)
|
||||
for (__typeof__((arr)[0])* var = arr; (var) < (arr) + SPA_N_ELEMENTS(arr); (var)++)
|
||||
|
||||
#define SPA_ABS(a) \
|
||||
({ \
|
||||
|
|
Loading…
Reference in a new issue