diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-02-28 01:30:28 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-02-28 03:29:26 +0300 |
commit | d5a55b69181a69d481b1e504f39926ec595dd6b8 (patch) | |
tree | 3ae8ead0a91741c98b5ba6856286c9a9c4e0d202 /source/blender/blenlib/BLI_link_utils.h | |
parent | 11100faa5cfbeb735194c6d2d5ed951dc5ae063a (diff) |
BLI_link_utils: Add BLI_LINKS_APPEND(list, link)
Diffstat (limited to 'source/blender/blenlib/BLI_link_utils.h')
-rw-r--r-- | source/blender/blenlib/BLI_link_utils.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_link_utils.h b/source/blender/blenlib/BLI_link_utils.h index d469b105f93..5322547ac08 100644 --- a/source/blender/blenlib/BLI_link_utils.h +++ b/source/blender/blenlib/BLI_link_utils.h @@ -35,6 +35,18 @@ list = link; \ } (void)0 +/* Use for append (single linked list, storing the last element). */ +#define BLI_LINKS_APPEND(list, link) { \ + (link)->next = NULL; \ + if ((list)->first) { \ + (list)->last->next = link; \ + } \ + else { \ + (list)->first = link; \ + } \ + (list)->last = link; \ +} (void)0 + #define BLI_LINKS_FREE(list) { \ while (list) { \ void *next = list->next; \ |