suppress clang-tidy warning for array and queue

This commit is contained in:
tezc 2021-04-01 03:24:25 +03:00
parent 6f4040aa03
commit 535a9229b0
2 changed files with 11 additions and 7 deletions

View File

@ -55,6 +55,7 @@ struct sc_array
bool sc_array_init(void *arr, size_t elem_size, size_t cap);
void sc_array_term(void *arr);
bool sc_array_expand(void *arr, size_t elem_size);
#define sc_array_sizeof(a) (sizeof(a)) // NOLINT
// Internals end
/**
@ -62,7 +63,8 @@ bool sc_array_expand(void *arr, size_t elem_size);
* @param cap initial capacity. '0' is a valid initial capacity.
* @return 'true' on success, 'false' on out of memory
*/
#define sc_array_create(arr, cap) sc_array_init(&(arr), sizeof(*(arr)), cap)
#define sc_array_create(arr, cap) \
sc_array_init(&(arr), sc_array_sizeof(*(arr)), cap)
/**
* @param arr array to be destroyed
@ -93,7 +95,7 @@ bool sc_array_expand(void *arr, size_t elem_size);
* @return 'true' on success, 'false' on out of memory.
*/
#define sc_array_add(arr, elem) \
sc_array_expand(&((arr)), sizeof(*(arr))) == true ? \
sc_array_expand(&((arr)), sc_array_sizeof(*(arr))) == true ? \
(arr)[sc_array_meta(arr)->size++] = (elem), \
true : false
@ -143,7 +145,7 @@ bool sc_array_expand(void *arr, size_t elem_size);
* @param cmp comparator, check qsort() documentation for details
*/
#define sc_array_sort(arr, cmp) \
(qsort((arr), sc_array_size((arr)), sizeof(*(arr)), cmp))
(qsort((arr), sc_array_size((arr)), sc_array_sizeof(*(arr)), cmp))
/**
* @param arr array

View File

@ -90,13 +90,15 @@ static inline size_t sc_queue_dec_last(void *q)
bool sc_queue_init(void *q, size_t elem_size, size_t cap);
void sc_queue_term(void *q);
bool sc_queue_expand(void *q, size_t elem_size);
#define sc_queue_sizeof(a) (sizeof(a)) // NOLINT
/**
* @param q queue
* @param count initial capacity, '0' is accepted.
* @return 'true' on success, 'false' on out of memory.
*/
#define sc_queue_create(q, count) sc_queue_init(&(q), sizeof(*(q)), count)
#define sc_queue_create(q, count) \
sc_queue_init(&(q), sc_queue_sizeof(*(q)), count)
/**
* Destroy queue
@ -184,7 +186,7 @@ bool sc_queue_expand(void *q, size_t elem_size);
* @return 'true' on success, 'false' on out of memory.
*/
#define sc_queue_add_last(q, elem) \
sc_queue_expand(&(q), sizeof(*(q))) == true ? \
sc_queue_expand(&(q), sc_queue_sizeof(*(q))) == true ? \
(q)[sc_queue_inc_last((q))] = (elem), \
true : false
@ -201,7 +203,7 @@ bool sc_queue_expand(void *q, size_t elem_size);
* @return 'true' on success, 'false' on out of memory.
*/
#define sc_queue_add_first(q, elem) \
sc_queue_expand(&(q), sizeof(*(q))) == true ? \
sc_queue_expand(&(q), sc_queue_sizeof(*(q))) == true ? \
(q)[sc_queue_dec_first((q))] = (elem), \
true : false