diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-08-27 03:37:08 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-08-27 03:37:08 +0400 |
commit | 8ef934c73f3baeaa582efb8de906b27a3854979c (patch) | |
tree | 95dcb068fc96b3323e6ffe425ee6a7481b23eab4 /source/blender/blenlib/intern/listbase.c | |
parent | cdd57d499434061de35af23790c993220922b206 (diff) |
ghash/bli-listbase edits, rename BLI_ghash_pop -> BLI_ghash_popkey (since it takes a key as an arg and isnt popping any element from the hash as you might expect).
add BLI_pophead/tail, since getting the first element from a list and removing it is a common task.
Diffstat (limited to 'source/blender/blenlib/intern/listbase.c')
-rw-r--r-- | source/blender/blenlib/intern/listbase.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c index ded4f31ae05..c4644ff6309 100644 --- a/source/blender/blenlib/intern/listbase.c +++ b/source/blender/blenlib/intern/listbase.c @@ -129,6 +129,30 @@ bool BLI_remlink_safe(ListBase *listbase, void *vlink) } } +/** + * Removes the head from \a listbase and returns it. + */ +void *BLI_pophead(ListBase *listbase) +{ + Link *link; + if ((link = listbase->first)) { + BLI_remlink(listbase, link); + } + return link; +} + + +/** + * Removes the tail from \a listbase and returns it. + */ +void *BLI_poptail(ListBase *listbase) +{ + Link *link; + if ((link = listbase->last)) { + BLI_remlink(listbase, link); + } + return link; +} /** * Removes \a vlink from listbase and disposes of it. Assumes it is linked into there! |