diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2018-05-28 10:15:09 -0300 |
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2018-08-13 18:59:31 -0300 |
| commit | 9ea82f28d499f2bf5668fde86474b3e5287e58c6 (patch) | |
| tree | 477b4f8d87db2932d745af59a69cba33d8a6e7f4 /lib/linklist.h | |
| parent | 27982ebc9d211a9353029a043a120fdf291f5171 (diff) | |
lib: add listnode_add_head()
Provide a new convenience function that adds an element to the beginning
of a list.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/linklist.h')
| -rw-r--r-- | lib/linklist.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/linklist.h b/lib/linklist.h index cee6c1e505..f5cd44efb0 100644 --- a/lib/linklist.h +++ b/lib/linklist.h @@ -83,6 +83,19 @@ extern struct list *list_new(void); extern void listnode_add(struct list *list, void *data); /* + * Add a new element to the beginning of a list. + * + * Runtime is O(1). + * + * list + * list to operate on + * + * data + * element to add + */ +extern void listnode_add_head(struct list *list, void *data); + +/* * Insert a new element into a list with insertion sort. * * If list->cmp is set, this function is used to determine the position to |
