| 1001 | } |
| 1002 | |
| 1003 | int acl_htable_reset(ACL_HTABLE *table, void (*free_fn) (void *)) |
| 1004 | { |
| 1005 | unsigned i = table->size; |
| 1006 | ACL_HTABLE_INFO *ht; |
| 1007 | ACL_HTABLE_INFO *next; |
| 1008 | ACL_HTABLE_INFO **h; |
| 1009 | int ret; |
| 1010 | |
| 1011 | LOCK_TABLE_WRITE(table); |
| 1012 | |
| 1013 | h = table->data; |
| 1014 | |
| 1015 | while (i-- > 0) { |
| 1016 | for (ht = *h++; ht; ht = next) { |
| 1017 | next = ht->next; |
| 1018 | if (!(table->flag & ACL_HTABLE_FLAG_KEY_REUSE)) { |
| 1019 | if (table->slice) { |
| 1020 | acl_slice_pool_free(__FILE__, __LINE__, |
| 1021 | ht->key.key); |
| 1022 | } else { |
| 1023 | acl_myfree(ht->key.key); |
| 1024 | } |
| 1025 | } |
| 1026 | |
| 1027 | if (free_fn && ht->value) { |
| 1028 | (*free_fn) (ht->value); |
| 1029 | } |
| 1030 | |
| 1031 | if (table->slice) { |
| 1032 | acl_slice_pool_free(__FILE__, __LINE__, ht); |
| 1033 | } else { |
| 1034 | acl_myfree(ht); |
| 1035 | } |
| 1036 | } |
| 1037 | } |
| 1038 | |
| 1039 | if (table->slice) { |
| 1040 | acl_slice_pool_free(__FILE__, __LINE__, table->data); |
| 1041 | } else { |
| 1042 | acl_myfree(table->data); |
| 1043 | } |
| 1044 | |
| 1045 | ret = htable_size(table, table->init_size < 13 ? 13 : table->init_size); |
| 1046 | |
| 1047 | UNLOCK_TABLE(table); |
| 1048 | return ret; |
| 1049 | } |
| 1050 | |
| 1051 | const ACL_HTABLE_INFO *acl_htable_iter_head(ACL_HTABLE *table, ACL_HTABLE_ITER *iter) |
| 1052 | { |
no test coverage detected
searching dependent graphs…