Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-02-07 23:07:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-02-07 23:24:05 +0400
commitb3afbcab8ff2330c1473647be330a3ffe9b11885 (patch)
treee86b9c7d9676e63b8da92da79889dee13b8be186 /source/blender/blenlib/BLI_listbase.h
parent1c24d954f4ac63f22b703756b6664a4ad1b363d4 (diff)
ListBase API: add utility api funcs for clearing and checking empty
Diffstat (limited to 'source/blender/blenlib/BLI_listbase.h')
-rw-r--r--source/blender/blenlib/BLI_listbase.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h
index 0927620a2c6..77490929efb 100644
--- a/source/blender/blenlib/BLI_listbase.h
+++ b/source/blender/blenlib/BLI_listbase.h
@@ -77,6 +77,13 @@ void BLI_reverselist(struct ListBase *lb);
void BLI_rotatelist_first(struct ListBase *lb, void *vlink);
void BLI_rotatelist_last(struct ListBase *lb, void *vlink);
+/**
+ * Utility functions to avoid first/last references inline all over.
+ */
+BLI_INLINE bool BLI_listbase_is_single(const struct ListBase *lb) { return (lb->first && lb->first == lb->last); }
+BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb) { return (lb->first == NULL); }
+BLI_INLINE void BLI_listbase_clear(struct ListBase *lb) { lb->first = lb->last = NULL; }
+
/* create a generic list node containing link to provided data */
struct LinkData *BLI_genericNodeN(void *data);