File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed
Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -179,19 +179,21 @@ static int hashmap_rehash(struct hashmap_base *hb, size_t table_size)
179179 hb -> table_size = table_size ;
180180 hb -> table = new_table ;
181181
182- /* Rehash */
183- for (entry = old_table ; entry < old_table + old_size ; ++ entry ) {
184- if (!entry -> key ) {
185- continue ;
186- }
187- new_entry = hashmap_entry_find (hb , entry -> key , true);
188- /* Failure indicates an algorithm bug */
189- assert (new_entry != NULL );
182+ /* Rehash all existing entries */
183+ if (old_table ) {
184+ for (entry = old_table ; entry < old_table + old_size ; ++ entry ) {
185+ if (!entry -> key ) {
186+ continue ;
187+ }
188+ new_entry = hashmap_entry_find (hb , entry -> key , true);
189+ /* Failure indicates an algorithm bug */
190+ assert (new_entry != NULL );
190191
191- /* Shallow copy */
192- * new_entry = * entry ;
192+ /* Shallow copy */
193+ * new_entry = * entry ;
194+ }
195+ free (old_table );
193196 }
194- free (old_table );
195197 return 0 ;
196198}
197199
You can’t perform that action at this time.
0 commit comments