[Bf-blender-cvs] [dcc3617] master: BLI_stack: use strict flags also use size_t, rename BLI_stack_empty

Campbell Barton noreply at git.blender.org
Sat Jun 28 15:18:33 CEST 2014


Commit: dcc361708c3a8af16d433ce0326e292f8d4732cc
Author: Campbell Barton
Date:   Sat Jun 28 23:07:32 2014 +1000
https://developer.blender.org/rBdcc361708c3a8af16d433ce0326e292f8d4732cc

BLI_stack: use strict flags
also use size_t, rename BLI_stack_empty

===================================================================

M	source/blender/blenlib/BLI_stack.h
M	source/blender/blenlib/intern/stack.c
M	source/blender/modifiers/intern/MOD_skin.c

===================================================================

diff --git a/source/blender/blenlib/BLI_stack.h b/source/blender/blenlib/BLI_stack.h
index 564ff51..ac96195 100644
--- a/source/blender/blenlib/BLI_stack.h
+++ b/source/blender/blenlib/BLI_stack.h
@@ -31,7 +31,7 @@
 typedef struct BLI_Stack BLI_Stack;
 
 /* Create a new homogeneous stack with elements of 'elem_size' bytes */
-BLI_Stack *BLI_stack_new(int elem_size, const char *description);
+BLI_Stack *BLI_stack_new(size_t elem_size, const char *description);
 
 /* Free the stack's data and the stack itself */
 void BLI_stack_free(BLI_Stack *stack);
@@ -49,6 +49,6 @@ void BLI_stack_push(BLI_Stack *stack, void *src);
 void BLI_stack_pop(BLI_Stack *stack, void *dst);
 
 /* Returns true if the stack is empty, false otherwise */
-int BLI_stack_empty(const BLI_Stack *stack);
+bool BLI_stack_is_empty(const BLI_Stack *stack);
 
 #endif
diff --git a/source/blender/blenlib/intern/stack.c b/source/blender/blenlib/intern/stack.c
index 5be2ed9..b0177cc 100644
--- a/source/blender/blenlib/intern/stack.c
+++ b/source/blender/blenlib/intern/stack.c
@@ -28,21 +28,23 @@
 #include <string.h>
 #include <stdlib.h>  /* abort() */
 
-#include "BLI_stack.h"  /* own include */
-
 #include "BLI_utildefines.h"
 #include "MEM_guardedalloc.h"
 
+#include "BLI_stack.h"  /* own include */
+
+#include "BLI_strict_flags.h"
+
 struct BLI_Stack {
 	void *data;
 
-	int totelem;
-	int maxelem;
+	size_t totelem;
+	size_t maxelem;
 
-	int elem_size;
+	size_t elem_size;
 };
 
-BLI_Stack *BLI_stack_new(int elem_size, const char *description)
+BLI_Stack *BLI_stack_new(size_t elem_size, const char *description)
 {
 	BLI_Stack *stack = MEM_callocN(sizeof(*stack), description);
 
@@ -74,11 +76,11 @@ void BLI_stack_push(BLI_Stack *stack, void *src)
 			 * number of elements */
 			stack->maxelem = 32;
 			stack->data = MEM_mallocN((stack->elem_size *
-			                           stack->maxelem), AT);
+			                           stack->maxelem), __func__);
 		}
 		else {
 			/* Double stack size */
-			int maxelem = stack->maxelem + stack->maxelem;
+			size_t maxelem = stack->maxelem + stack->maxelem;
 			/* Check for overflow */
 			BLI_assert(maxelem > stack->maxelem);
 			stack->data = MEM_reallocN(stack->data,
@@ -104,7 +106,7 @@ void BLI_stack_pop(BLI_Stack *stack, void *dst)
 	}
 }
 
-int BLI_stack_empty(const BLI_Stack *stack)
+bool BLI_stack_is_empty(const BLI_Stack *stack)
 {
 	return stack->totelem == 0;
 }
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 832565c..825015f 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -732,7 +732,7 @@ static EMat *build_edge_mats(const MVertSkin *vs,
 		}
 	}
 
-	while (!BLI_stack_empty(stack)) {
+	while (!BLI_stack_is_empty(stack)) {
 		build_emats_stack(stack, visited_e, emat, emap, medge, vs, mvert);
 	}




More information about the Bf-blender-cvs mailing list