Skip to content

Commit acc6937

Browse files
committed
update aws_policy_equal.c
1 parent c8de512 commit acc6937

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/aws_policy_equal/aws_policy_equal.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ static const char *unordered_arrays[] = {
4444
// Count of unordered array fields
4545
#define UNORDERED_ARRAYS_COUNT (sizeof(unordered_arrays) / sizeof(unordered_arrays[0]))
4646

47+
// Forward declarations
48+
static cJSON_bool aws_policy_compare_items(const cJSON *a, const cJSON *b, int parent_is_unordered);
49+
4750
// Check if a field name is in the list of unordered arrays
4851
static int is_unordered_array(const char *field_name) {
4952
for (int i = 0; i < UNORDERED_ARRAYS_COUNT; i++) {
@@ -73,6 +76,12 @@ static int aws_service_compare(const char *str1, const char *str2) {
7376
return *str1 == *str2;
7477
}
7578

79+
// Compare doubles with appropriate epsilon
80+
static cJSON_bool compare_double(double a, double b) {
81+
double maxVal = fabs(a) > fabs(b) ? fabs(a) : fabs(b);
82+
return (fabs(a - b) <= maxVal * DBL_EPSILON);
83+
}
84+
7685
// Find an element in an array by value (for unordered comparison)
7786
static cJSON *find_matching_element(const cJSON *array, const cJSON *item, int parent_is_unordered) {
7887
cJSON *element;
@@ -211,17 +220,6 @@ static cJSON_bool aws_policy_compare_items(const cJSON *a, const cJSON *b, int p
211220
}
212221
}
213222

214-
// Forward declarations
215-
static cJSON_bool aws_policy_compare_items(const cJSON *a, const cJSON *b, int parent_is_unordered);
216-
static cJSON *find_matching_element(const cJSON *array, const cJSON *item, int parent_is_unordered);
217-
static cJSON_bool compare_double(double a, double b);
218-
219-
// Compare doubles with appropriate epsilon
220-
static cJSON_bool compare_double(double a, double b) {
221-
double maxVal = fabs(a) > fabs(b) ? fabs(a) : fabs(b);
222-
return (fabs(a - b) <= maxVal * DBL_EPSILON);
223-
}
224-
225223
static void aws_policy_equal(sqlite3_context *context, int argc, sqlite3_value **argv) {
226224
if (argc != 2) {
227225
sqlite3_result_error(context, "aws_policy_equal() requires exactly two arguments", -1);

0 commit comments

Comments
 (0)