| 23 | #include "../mem/rpm_mem.h" |
| 24 | |
| 25 | int hash_init_locks(gen_hash_t *h) |
| 26 | { |
| 27 | unsigned int n; |
| 28 | gen_lock_set_t *locks = NULL; |
| 29 | |
| 30 | for (n = h->size; n >= 1 && !locks; n/=2) { |
| 31 | locks = lock_set_alloc(n); |
| 32 | if (locks && lock_set_init(locks)) |
| 33 | break; |
| 34 | } |
| 35 | |
| 36 | if (!locks) { |
| 37 | LM_ERR("could not allocate hash locks\n"); |
| 38 | return -1; |
| 39 | } |
| 40 | h->locks = locks; |
| 41 | h->locks_no = n; |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | gen_hash_t *hash_init_flags(unsigned int size, unsigned int flags) |
| 46 | { |
no test coverage detected