Ignore:
Timestamp:
2018-03-14T18:54:08Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
67f11a0
Parents:
963037b0
Message:

Make hash_table_find_next immune to livelocks

By giving hash_table_find_next the item returned from hash_table_find,
we provide it with a fixed reference with which the outer loop which
calls hash_table_find_next can terminate even if the respective bucket
contains more matching elements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/adt/hash_table.c

    r963037b0 r30f1a25  
    269269
    270270/** Find the next item equal to item. */
    271 ht_link_t *hash_table_find_next(const hash_table_t *h, ht_link_t *item)
     271ht_link_t *
     272hash_table_find_next(const hash_table_t *h, ht_link_t *first, ht_link_t *item)
    272273{
    273274        assert(item);
     
    277278
    278279        /* Traverse the circular list until we reach the starting item again. */
    279         for (link_t *cur = item->link.next; cur != &item->link; cur = cur->next) {
     280        for (link_t *cur = item->link.next; cur != &first->link;
     281            cur = cur->next) {
    280282                assert(cur);
    281283
Note: See TracChangeset for help on using the changeset viewer.