diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-07-10 05:04:29 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-07-10 05:14:32 +0300 |
commit | 8f24ec2e26ac634789ed9027dcfe6d1cd14782a7 (patch) | |
tree | 8afa02cf0343626f9eee3781629557709aca6ae3 /source/blender/blenlib/intern/BLI_linklist.c | |
parent | 3dd460aa7fbb7021130b58f7809cfda5b69df201 (diff) |
Cleanup: add BLI_linklist_find_last
This makes adding to the end of a linked list simpler,
In most cases we avoid this in favor of BLI_linklist_append.
For one off operations it's OK.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_linklist.c')
-rw-r--r-- | source/blender/blenlib/intern/BLI_linklist.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/BLI_linklist.c b/source/blender/blenlib/intern/BLI_linklist.c index 5020e06d0b3..dc5d20ece99 100644 --- a/source/blender/blenlib/intern/BLI_linklist.c +++ b/source/blender/blenlib/intern/BLI_linklist.c @@ -74,6 +74,16 @@ LinkNode *BLI_linklist_find(LinkNode *list, int index) return NULL; } +LinkNode *BLI_linklist_find_last(LinkNode *list) +{ + if (list) { + while (list->next) { + list = list->next; + } + } + return list; +} + void BLI_linklist_reverse(LinkNode **listp) { LinkNode *rhead = NULL, *cur = *listp; |