Commit 19783d8e authored by Brice Videau's avatar Brice Videau
Browse files

Added equality test for configurations.

parent 5b18cea8
......@@ -52,6 +52,10 @@ extern ccs_error_t
ccs_configuration_hash(ccs_configuration_t configuration,
ccs_hash_t *hash_ret);
extern ccs_error_t
ccs_configuration_equal(ccs_configuration_t configuration,
ccs_configuration_t other_configuration,
ccs_bool_t *equal_ret);
#ifdef __cplusplus
}
#endif
......
......@@ -181,3 +181,29 @@ ccs_configuration_hash(ccs_configuration_t configuration,
*hash_ret = h;
return CCS_SUCCESS;
}
ccs_error_t
ccs_configuration_equal(ccs_configuration_t configuration,
ccs_configuration_t other_configuration,
ccs_bool_t *equal_ret) {
if (!configuration || !configuration->data)
return -CCS_INVALID_OBJECT;
if (!other_configuration || !other_configuration->data)
return -CCS_INVALID_OBJECT;
if (!equal_ret)
return -CCS_INVALID_VALUE;
_ccs_configuration_data_t *data = configuration->data;
_ccs_configuration_data_t *other_data = other_configuration->data;
*equal_ret = CCS_FALSE;
if (data->configuration_space != other_data->configuration_space)
return CCS_SUCCESS;
if (data->num_values != other_data->num_values)
return CCS_SUCCESS;
for (size_t i = 0; i < data->num_values; i++) {
if (_datum_cmp(data->values + i, other_data->values + i))
return CCS_SUCCESS;
}
*equal_ret = CCS_TRUE;
return CCS_SUCCESS;
}
......@@ -55,7 +55,7 @@ static inline int _datum_cmp(ccs_datum_t *a, ccs_datum_t *b) {
return 0;
break;
default:
return memcmp(&(a->value), &(b->value), sizeof(ccs_value_t));
return memcmp(&(a->value), &(b->value), sizeof(ccs_value_t));
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment