Add int_array_includes()
This is a convenient helper function for using int_array instances. Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
This commit is contained in:
parent
094e188f84
commit
5f83f4db0b
2 changed files with 14 additions and 0 deletions
|
@ -990,6 +990,19 @@ void int_array_add_unique(int **res, int a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool int_array_includes(int *arr, int val)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; arr && arr[i]; i++) {
|
||||||
|
if (val == arr[i])
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void str_clear_free(char *str)
|
void str_clear_free(char *str)
|
||||||
{
|
{
|
||||||
if (str) {
|
if (str) {
|
||||||
|
|
|
@ -577,6 +577,7 @@ size_t int_array_len(const int *a);
|
||||||
void int_array_concat(int **res, const int *a);
|
void int_array_concat(int **res, const int *a);
|
||||||
void int_array_sort_unique(int *a);
|
void int_array_sort_unique(int *a);
|
||||||
void int_array_add_unique(int **res, int a);
|
void int_array_add_unique(int **res, int a);
|
||||||
|
bool int_array_includes(int *arr, int val);
|
||||||
|
|
||||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue