linked list: inline list init functions
These functions are so trivial it's always cheaper to inline them. Change-Id: Ie0c77c8b6e7a716312105445a22e62ff57a76d90
This commit is contained in:
parent
8bf8036021
commit
ee9679993b
2 changed files with 31 additions and 32 deletions
|
@ -45,15 +45,6 @@ static struct ll_node * ll_search_prev(struct ll_head *list,
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the singly-linked list
|
|
||||||
*/
|
|
||||||
void ll_init(struct ll_head *list)
|
|
||||||
{
|
|
||||||
list->head = NULL;
|
|
||||||
list->tail = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a node to s singly-linked list using "insert next"
|
* Adds a node to s singly-linked list using "insert next"
|
||||||
*/
|
*/
|
||||||
|
@ -142,18 +133,6 @@ void ll_remove(struct ll_head *list, struct ll_node *node)
|
||||||
|
|
||||||
/** (L)inked (L)ist (D)ouble **/
|
/** (L)inked (L)ist (D)ouble **/
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the doubly-linked list
|
|
||||||
*/
|
|
||||||
void lld_init(struct lld_head *list)
|
|
||||||
{
|
|
||||||
list->head = NULL;
|
|
||||||
list->tail = NULL;
|
|
||||||
|
|
||||||
/* tail could be stored in first item's prev pointer but this simplifies
|
|
||||||
the routines and maintains the non-circularity */
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a node to a doubly-linked list using "insert first"
|
* Adds a node to a doubly-linked list using "insert first"
|
||||||
*/
|
*/
|
||||||
|
@ -237,14 +216,6 @@ static inline struct lldc_node * lldc_insert(struct lldc_head *list,
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the doubly-linked circular list
|
|
||||||
*/
|
|
||||||
void lldc_init(struct lldc_head *list)
|
|
||||||
{
|
|
||||||
list->head = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a node to a doubly-linked circular list using "insert first"
|
* Adds a node to a doubly-linked circular list using "insert first"
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#ifndef LINKED_LIST_H
|
#ifndef LINKED_LIST_H
|
||||||
#define LINKED_LIST_H
|
#define LINKED_LIST_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
/***
|
/***
|
||||||
** NOTES:
|
** NOTES:
|
||||||
** Node field order chosen so that one type can alias the other for forward
|
** Node field order chosen so that one type can alias the other for forward
|
||||||
|
@ -51,7 +53,15 @@ struct ll_node
|
||||||
struct ll_node *next; /* Next list item */
|
struct ll_node *next; /* Next list item */
|
||||||
};
|
};
|
||||||
|
|
||||||
void ll_init(struct ll_head *list);
|
/**
|
||||||
|
* Initializes the singly-linked list
|
||||||
|
*/
|
||||||
|
static inline void ll_init(struct ll_head *list)
|
||||||
|
{
|
||||||
|
list->head = NULL;
|
||||||
|
list->tail = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void ll_insert_next(struct ll_head *list, struct ll_node *node,
|
void ll_insert_next(struct ll_head *list, struct ll_node *node,
|
||||||
struct ll_node *newnode);
|
struct ll_node *newnode);
|
||||||
void ll_insert_last(struct ll_head *list, struct ll_node *node);
|
void ll_insert_last(struct ll_head *list, struct ll_node *node);
|
||||||
|
@ -81,7 +91,18 @@ struct lld_node
|
||||||
struct lld_node *prev; /* Previous list item */
|
struct lld_node *prev; /* Previous list item */
|
||||||
};
|
};
|
||||||
|
|
||||||
void lld_init(struct lld_head *list);
|
/**
|
||||||
|
* Initializes the doubly-linked list
|
||||||
|
*/
|
||||||
|
static inline void lld_init(struct lld_head *list)
|
||||||
|
{
|
||||||
|
list->head = NULL;
|
||||||
|
list->tail = NULL;
|
||||||
|
|
||||||
|
/* tail could be stored in first item's prev pointer but this simplifies
|
||||||
|
the routines and maintains the non-circularity */
|
||||||
|
}
|
||||||
|
|
||||||
void lld_insert_first(struct lld_head *list, struct lld_node *node);
|
void lld_insert_first(struct lld_head *list, struct lld_node *node);
|
||||||
void lld_insert_last(struct lld_head *list, struct lld_node *node);
|
void lld_insert_last(struct lld_head *list, struct lld_node *node);
|
||||||
void lld_remove(struct lld_head *list, struct lld_node *node);
|
void lld_remove(struct lld_head *list, struct lld_node *node);
|
||||||
|
@ -106,7 +127,14 @@ struct lldc_node
|
||||||
struct lldc_node *prev; /* Previous list item */
|
struct lldc_node *prev; /* Previous list item */
|
||||||
};
|
};
|
||||||
|
|
||||||
void lldc_init(struct lldc_head *list);
|
/**
|
||||||
|
* Initializes the doubly-linked circular list
|
||||||
|
*/
|
||||||
|
static inline void lldc_init(struct lldc_head *list)
|
||||||
|
{
|
||||||
|
list->head = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void lldc_insert_first(struct lldc_head *list, struct lldc_node *node);
|
void lldc_insert_first(struct lldc_head *list, struct lldc_node *node);
|
||||||
void lldc_insert_last(struct lldc_head *list, struct lldc_node *node);
|
void lldc_insert_last(struct lldc_head *list, struct lldc_node *node);
|
||||||
void lldc_remove(struct lldc_head *list, struct lldc_node *node);
|
void lldc_remove(struct lldc_head *list, struct lldc_node *node);
|
||||||
|
|
Loading…
Reference in a new issue