| 1 | #include <aws/common/hash_table.h> |
| 2 | #include <aws/common/math.h> |
| 3 | #include <aws/common/private/hash_table_impl.h> |
| 4 | #include <aws/common/string.h> |
| 5 | |
| 6 | #include <limits.h> |
| 7 | #include <proof_helpers/make_common_data_structures.h> |
| 8 | #include <proof_helpers/utils.h> |
| 9 | #include <stdio.h> |
| 10 | #include <stdlib.h> |
| 11 | bool __CPROVER_file_local_hash_table_c_s_hash_keys_eq(struct hash_table_state *state, const void *a, const void *b); |
| 12 | |
| 13 | int aws_hash_table_find(const struct aws_hash_table *map, const void *key, struct aws_hash_element **p_elem) { |
| 14 | AWS_PRECONDITION(aws_hash_table_is_valid(map), "Input hash_table [map] must be valid."); |
| 15 | AWS_PRECONDITION(AWS_OBJECT_PTR_IS_WRITABLE(p_elem), "Input pointer [p_elem] must be writable."); |
| 16 | |
| 17 | const struct hash_table_state *const state = map->p_impl; |
| 18 | size_t i; |
| 19 | |
| 20 | __CPROVER_assume(i < state->size); |
| 21 | if (nondet_bool()) { |
| 22 | *p_elem = NULL; |
| 23 | } else { |
| 24 | const struct hash_table_entry *const entry = &state->slots[i]; |
| 25 | __CPROVER_assume(__CPROVER_file_local_hash_table_c_s_hash_keys_eq(state, key, entry->element.key)); |
| 26 | *p_elem = &entry->element; |
| 27 | } |
| 28 | AWS_POSTCONDITION(aws_hash_table_is_valid(map), "Output hash_table [map] must be valid."); |
| 29 | return AWS_OP_SUCCESS; |
| 30 | } |