Utility macros for linklist stack & asserts for bmesh
authorCampbell Barton <ideasman42@gmail.com>
Fri, 9 May 2014 22:46:35 +0000 (08:46 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 9 May 2014 23:29:34 +0000 (09:29 +1000)
source/blender/blenlib/BLI_linklist_stack.h
source/blender/bmesh/intern/bmesh_core.c

index 1933dd733c35f28ce0539f7f490da0e2e5fdb6ee..5f4f98c5a4f6542ef0b7ab2ceb95a655c9d52ef0 100644 (file)
        (_BLI_SMALLSTACK_CAST(var_src) ((_##var_src##_stack) ? \
        (_BLI_SMALLSTACK_DEL_EX(var_src, var_dst), (_##var_dst##_free->link)) : NULL))
 
+#define BLI_SMALLSTACK_LAST(var) \
+       (_BLI_SMALLSTACK_CAST(var) ((_##var##_stack) ? \
+                                    _##var##_stack->link : NULL))
+
+#define BLI_SMALLSTACK_IS_EMPTY(var) \
+       (_BLI_SMALLSTACK_CAST(var) (_##var##_stack != NULL))
+
 /* loop over stack members last-added-first */
 #define BLI_SMALLSTACK_ITER_BEGIN(var, item) \
        { \
index 4c70305476f30a3582c55f720b7f163de4adb5e6..1f81b59badc3974583f0c121eb9614e46079152e 100644 (file)
@@ -132,7 +132,10 @@ BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2,
                        const BMEdge *e_example, const eBMCreateFlag create_flag)
 {
        BMEdge *e;
-       
+
+       BLI_assert(v1 != v2);
+       BLI_assert(v1->head.htype == BM_VERT && v2->head.htype == BM_VERT);
+
        if ((create_flag & BM_CREATE_NO_DOUBLE) && (e = BM_edge_exists(v1, v2)))
                return e;