File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,7 @@ __h_insert_get_next_free(struct h_insert_scratch *scratch,
152152 element_is_empty_t is_empty_func )
153153{
154154 h_index_t index_to_ret = scratch -> next_free_index ;
155+ void * free_slot ;
155156
156157 if (WARN_ON_ONCE (index_to_ret >= scratch -> table_size )) {
157158 /*
@@ -161,6 +162,16 @@ __h_insert_get_next_free(struct h_insert_scratch *scratch,
161162 return 0 ;
162163 }
163164
165+ free_slot = scratch -> table + index_to_ret * scratch -> elem_size ;
166+ while (!is_empty_func (free_slot )) {
167+ if (WARN_ON_ONCE (index_to_ret == 0 )) {
168+ /* We unexpectedly used up all slots. */
169+ return 0 ;
170+ }
171+ index_to_ret -- ;
172+ free_slot = scratch -> table + index_to_ret * scratch -> elem_size ;
173+ }
174+
164175 if (index_to_ret == 0 )
165176 scratch -> next_free_index = scratch -> table_size ;
166177 else
You can’t perform that action at this time.
0 commit comments