Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/include/sof/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,24 @@ static inline void list_item_append(struct list_item *item,
list->prev = item;
}

/* delete item from the list */
/* delete item from the list leaves deleted list item
*in undefined state list_is_empty won't return true
*/
static inline void list_item_del(struct list_item *item)
{
item->next->prev = item->prev;
item->prev->next = item->next;
}

/* delete item from the list list iteam will be reinitialised
* and list_is_empty will return true
*/
static inline void list_item_del_init(struct list_item *item)
{
list_item_del(item);
list_init(item);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you init only the item not the list.
What do you mean by

and list_is_empty will return true

@jajanusz jajanusz Sep 4, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you init only the item not the list.

Item and list are interchangable, depends on how you use it

and list_is_empty will return true

When you just del item it still has pointers pointing to items in list it's not part of. When you init item it's just like newly created item that is not part of any list and will return true for list_is_empty - it doesn't check for null it next but if next == 'this item'

}

/* is list item the last item in list ? */
static inline int list_item_is_last(struct list_item *item,
struct list_item *list)
Expand Down