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:
Andrei Otcheretianski 2024-05-08 16:42:12 +03:00 committed by Jouni Malinen
parent 094e188f84
commit 5f83f4db0b
2 changed files with 14 additions and 0 deletions

View file

@ -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)
{
if (str) {

View file

@ -577,6 +577,7 @@ size_t int_array_len(const int *a);
void int_array_concat(int **res, const int *a);
void int_array_sort_unique(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]))