Resize the table to the minimal size that contains all the elements, * but with the invariant of a USED/BUCKETS ratio near to <= 1 */
| 129 | /* Resize the table to the minimal size that contains all the elements, |
| 130 | * but with the invariant of a USED/BUCKETS ratio near to <= 1 */ |
| 131 | int dictResize(dict *d) |
| 132 | { |
| 133 | unsigned long minimal; |
| 134 | |
| 135 | if (!dict_can_resize || dictIsRehashing(d)) return DICT_ERR; |
| 136 | minimal = d->ht[0].used; |
| 137 | if (minimal < DICT_HT_INITIAL_SIZE) |
| 138 | minimal = DICT_HT_INITIAL_SIZE; |
| 139 | return dictExpand(d, minimal); |
| 140 | } |
| 141 | |
| 142 | /* Expand or create the hash table, |
| 143 | * when malloc_failed is non-NULL, it'll avoid panic if malloc fails (in which case it'll be set to 1). |
no test coverage detected