]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
int_array: Add a function to check for equality
authorRohan Dutta <quic_drohan@quicinc.com>
Fri, 21 Mar 2025 09:38:04 +0000 (15:08 +0530)
committerJouni Malinen <j@w1.fi>
Sat, 22 Mar 2025 08:53:32 +0000 (10:53 +0200)
Add int_array_equal() to allow comparison of two int_array
instances. Return true if both arrays included the same set of integers.

Co-developed-by: Pooventhiran G <quic_pooventh@quicinc.com>
Signed-off-by: Pooventhiran G <quic_pooventh@quicinc.com>
Signed-off-by: Rohan Dutta <quic_drohan@quicinc.com>
src/utils/common.c
src/utils/common.h

index d5e51a7924894c8af502336f225e422ebe4d0f6e..eb5a68b4957d5fec9b1fc263bb8e84c9db431322 100644 (file)
@@ -1003,6 +1003,28 @@ bool int_array_includes(const int *arr, int val)
 }
 
 
+bool int_array_equal(const int *a, const int *b)
+{
+       size_t alen, blen, i;
+
+       if (!a || !b)
+               return false;
+
+       alen = int_array_len(a);
+       blen = int_array_len(b);
+
+       if (alen != blen)
+               return false;
+
+       for (i = 0; i <= alen; i++) {
+               if (!int_array_includes(b, a[i]))
+                       return false;
+       }
+
+       return true;
+}
+
+
 void str_clear_free(char *str)
 {
        if (str) {
index f1c46599e759dfdc5d7b67bb7724cef6739f5421..d7b3600f27e474c8134bf2e491ff2da1b0259ff6 100644 (file)
@@ -595,6 +595,7 @@ 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(const int *arr, int val);
+bool int_array_equal(const int *a, const int *b);
 
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))