Changeset 437 for trunk/kernel/libk


Ignore:
Timestamp:
Mar 28, 2018, 2:40:29 PM (7 years ago)
Author:
alain
Message:

Fix various bugs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/libk/list.h

    r24 r437  
    9797#define LIST_LAST( root , type , member )               \
    9898        LIST_ELEMENT( (root)->pred , type , member )
    99 
    100 /***************************************************************************
    101  * This function returns the pointer on the next list_entry_t.
    102  ***************************************************************************
    103  * @ root    : pointer on the list root.
    104  * @ current : pointer on the current list_entry_t.
    105  * @ returns pointer on next entry if success.
    106  *   returns NULL if list empty or next is the root.
    107  **************************************************************************/
    108 static inline list_entry_t * list_next( list_entry_t * root,
    109                                         list_entry_t * current )
    110 {
    111         if((root == root->next) || (current->next == root)) return NULL;
    112  
    113         return current->next;
    114 }
    115 
    116 /***************************************************************************
    117  * This function returns the pointer on the previous list_entry_t.
    118  ***************************************************************************
    119  * @ root    : pointer on the list root.
    120  * @ current : pointer on the current list_entry.
    121  * @ returns pointer on previous entry if success.
    122  *   returns NULL if list empty or previous is the root.
    123  **************************************************************************/
    124 static inline list_entry_t * list_pred( list_entry_t * root,
    125                                         list_entry_t * current )
    126 {
    127         if((root == root->next) || (current->pred == root))
    128                 return NULL;
    129  
    130         return current->pred;
    131 }
    13299
    133100/***************************************************************************
     
    211178                                  list_entry_t * entry )
    212179{
    213     list_add_first( root->pred , entry );
     180    list_entry_t * pred_entry;
     181    list_entry_t * next_entry;
     182
     183        pred_entry = root->pred;
     184        next_entry = root;
     185       
     186        entry->next = next_entry;
     187        entry->pred = pred_entry;
     188 
     189        pred_entry->next = entry;
     190        next_entry->pred = entry;
    214191}
    215192
Note: See TracChangeset for help on using the changeset viewer.