]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add int_array_includes()
authorAndrei Otcheretianski <andrei.otcheretianski@intel.com>
Wed, 8 May 2024 13:42:12 +0000 (16:42 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 12 Jul 2024 09:58:05 +0000 (12:58 +0300)
This is a convenient helper function for using int_array instances.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
src/utils/common.c
src/utils/common.h

index 6acfcbd898429c4c938a4cdfcb64830efc0d2ce7..d62dec721b5646d6d1929ee691802c042f1b5d62 100644 (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) {
index 7d99b29190f6c73a01beb01948c5a298bf6349fd..dc2177537674f178e61542d85a5095befe1cdb10 100644 (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]))