mirror of
https://github.com/tezc/sc.git
synced 2025-01-14 06:43:04 +08:00
suppress clang-tidy warning for array and queue
This commit is contained in:
parent
6f4040aa03
commit
535a9229b0
@ -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
|
||||
|
@ -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
|
||||
|
||||
@ -224,7 +226,7 @@ bool sc_queue_expand(void *q, size_t elem_size);
|
||||
* }
|
||||
*/
|
||||
#define sc_queue_foreach(q, elem) \
|
||||
for (size_t _k = 1, _i = sc_queue_first(q); _k && _i != sc_queue_last(q); \
|
||||
for (size_t _k = 1, _i = sc_queue_first(q); _k && _i != sc_queue_last(q); \
|
||||
_k = !_k, _i = sc_queue_next(q, _i)) \
|
||||
for ((elem) = (q)[_i]; _k; _k = !_k)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user