mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04: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
1 changed files with 2 additions and 2 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue