Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 359f429 in mainline


Ignore:
Timestamp:
2011-09-09T15:05:00Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master
Children:
14a60e3
Parents:
bfbdfee
Message:

make list_remove() more robust

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/adt/list.h

    rbfbdfee r359f429  
    7272
    7373#define assert_link_not_used(link) \
    74         assert((link)->prev == NULL && (link)->next == NULL)
     74        assert(((link)->prev == NULL) && ((link)->next == NULL))
    7575
    7676/** Initialize doubly-linked circular list link
     
    158158static inline void list_remove(link_t *link)
    159159{
    160         link->next->prev = link->prev;
    161         link->prev->next = link->next;
     160        if ((link->prev != NULL) && (link->next != NULL)) {
     161                link->next->prev = link->prev;
     162                link->prev->next = link->next;
     163        }
     164       
    162165        link_initialize(link);
    163166}
Note: See TracChangeset for help on using the changeset viewer.