[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59698] trunk/blender/source/blender/ blenlib: use strict flags for lasso, boxpack, gsqueue and quadric's.

Campbell Barton ideasman42 at gmail.com
Sun Sep 1 05:43:10 CEST 2013


Revision: 59698
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59698
Author:   campbellbarton
Date:     2013-09-01 03:43:10 +0000 (Sun, 01 Sep 2013)
Log Message:
-----------
use strict flags for lasso, boxpack, gsqueue and quadric's.
for lasso also use unsigned ints rather then shorts for the path length.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_lasso.h
    trunk/blender/source/blender/blenlib/BLI_strict_flags.h
    trunk/blender/source/blender/blenlib/intern/boxpack2d.c
    trunk/blender/source/blender/blenlib/intern/gsqueue.c
    trunk/blender/source/blender/blenlib/intern/lasso.c
    trunk/blender/source/blender/blenlib/intern/quadric.c

Modified: trunk/blender/source/blender/blenlib/BLI_lasso.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_lasso.h	2013-09-01 03:37:45 UTC (rev 59697)
+++ trunk/blender/source/blender/blenlib/BLI_lasso.h	2013-09-01 03:43:10 UTC (rev 59698)
@@ -34,8 +34,8 @@
 
 struct rcti;
 
-void BLI_lasso_boundbox(struct rcti *rect, const int mcords[][2], const short moves);
-bool BLI_lasso_is_point_inside(const int mcords[][2], const short moves, const int sx, const int sy, const int error_value);
-bool BLI_lasso_is_edge_inside(const int mcords[][2], const short moves, int x0, int y0, int x1, int y1, const int error_value);
+void BLI_lasso_boundbox(struct rcti *rect, const int mcords[][2], const unsigned int moves);
+bool BLI_lasso_is_point_inside(const int mcords[][2], const unsigned int moves, const int sx, const int sy, const int error_value);
+bool BLI_lasso_is_edge_inside(const int mcords[][2], const unsigned int moves, int x0, int y0, int x1, int y1, const int error_value);
 
 #endif

Modified: trunk/blender/source/blender/blenlib/BLI_strict_flags.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_strict_flags.h	2013-09-01 03:37:45 UTC (rev 59697)
+++ trunk/blender/source/blender/blenlib/BLI_strict_flags.h	2013-09-01 03:43:10 UTC (rev 59698)
@@ -33,6 +33,9 @@
 #    pragma GCC diagnostic error "-Wsign-compare"
 #    pragma GCC diagnostic error "-Wconversion"
 #  endif
+#  if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408  /* gcc4.8+ only (behavior changed to ignore globals)*/
+#    pragma GCC diagnostic error "-Wshadow"
+#  endif
 #endif
 
 #endif  /* __BLI_STRICT_FLAGS_H__ */

Modified: trunk/blender/source/blender/blenlib/intern/boxpack2d.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/boxpack2d.c	2013-09-01 03:37:45 UTC (rev 59697)
+++ trunk/blender/source/blender/blenlib/intern/boxpack2d.c	2013-09-01 03:43:10 UTC (rev 59698)
@@ -27,8 +27,10 @@
 #include <stdlib.h> /* for qsort */
 
 #include "MEM_guardedalloc.h"
-#include "BLI_boxpack2d.h"
+#include "BLI_strict_flags.h"
 
+#include "BLI_boxpack2d.h"  /* own include */
+
 /* BoxPacker for backing 2D rectangles into a square
  * 
  * The defined Below are for internal use only */
@@ -169,11 +171,11 @@
 	}
 
 	/* Sort boxes, biggest first */
-	qsort(boxarray, len, sizeof(BoxPack), box_areasort);
+	qsort(boxarray, (size_t)len, sizeof(BoxPack), box_areasort);
 
 	/* add verts to the boxes, these are only used internally  */
-	vert = vertarray = MEM_mallocN(len * 4 * sizeof(BoxVert), "BoxPack Verts");
-	vertex_pack_indices = MEM_mallocN(len * 3 * sizeof(int), "BoxPack Indices");
+	vert = vertarray = MEM_mallocN((size_t)len * 4 * sizeof(BoxVert), "BoxPack Verts");
+	vertex_pack_indices = MEM_mallocN((size_t)len * 3 * sizeof(int), "BoxPack Indices");
 
 	for (box = boxarray, box_index = 0, i = 0; box_index < len; box_index++, box++) {
 
@@ -241,7 +243,7 @@
 		box_width = box->w;
 		box_height = box->h;
 
-		qsort(vertex_pack_indices, verts_pack_len, sizeof(int), vertex_sort);
+		qsort(vertex_pack_indices, (size_t)verts_pack_len, sizeof(int), vertex_sort);
 
 		/* Pack the box in with the others */
 		/* sort the verts */
@@ -318,7 +320,7 @@
 						(*tot_height) = max_ff(BOXTOP(box), (*tot_height));
 
 						/* Place the box */
-						vert->free &= ~quad_flags[j];
+						vert->free &= (short)~quad_flags[j];
 
 						switch (j) {
 							case TR:

Modified: trunk/blender/source/blender/blenlib/intern/gsqueue.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/gsqueue.c	2013-09-01 03:37:45 UTC (rev 59697)
+++ trunk/blender/source/blender/blenlib/intern/gsqueue.c	2013-09-01 03:43:10 UTC (rev 59698)
@@ -35,6 +35,7 @@
 
 #include "BLI_utildefines.h"
 #include "BLI_gsqueue.h"
+#include "BLI_strict_flags.h"
 
 typedef struct _GSQueueElem GSQueueElem;
 struct _GSQueueElem {
@@ -93,7 +94,7 @@
  */
 void BLI_gsqueue_peek(GSQueue *gq, void *item_r)
 {
-	memcpy(item_r, &gq->head[1], gq->elem_size);
+	memcpy(item_r, &gq->head[1], (size_t)gq->elem_size);
 }
 
 /**
@@ -114,7 +115,7 @@
 		gq->head = gq->head->next;
 	}
 	
-	if (item_r) memcpy(item_r, &elem[1], gq->elem_size);
+	if (item_r) memcpy(item_r, &elem[1], (size_t)gq->elem_size);
 	MEM_freeN(elem);
 }
 
@@ -130,11 +131,11 @@
 	
 	/* compare: prevent events added double in row */
 	if (!BLI_gsqueue_is_empty(gq)) {
-		if (0 == memcmp(item, &gq->head[1], gq->elem_size))
+		if (0 == memcmp(item, &gq->head[1], (size_t)gq->elem_size))
 			return;
 	}
-	elem = MEM_mallocN(sizeof(*elem) + gq->elem_size, "gqueue_push");
-	memcpy(&elem[1], item, gq->elem_size);
+	elem = MEM_mallocN(sizeof(*elem) + (size_t)gq->elem_size, "gqueue_push");
+	memcpy(&elem[1], item, (size_t)gq->elem_size);
 	elem->next = NULL;
 	
 	if (BLI_gsqueue_is_empty(gq)) {
@@ -154,8 +155,8 @@
  */
 void BLI_gsqueue_pushback(GSQueue *gq, void *item)
 {
-	GSQueueElem *elem = MEM_mallocN(sizeof(*elem) + gq->elem_size, "gqueue_push");
-	memcpy(&elem[1], item, gq->elem_size);
+	GSQueueElem *elem = MEM_mallocN(sizeof(*elem) + (size_t)gq->elem_size, "gqueue_push");
+	memcpy(&elem[1], item, (size_t)gq->elem_size);
 	elem->next = gq->head;
 
 	if (BLI_gsqueue_is_empty(gq)) {
@@ -176,5 +177,3 @@
 	}
 	MEM_freeN(gq);
 }
-
-

Modified: trunk/blender/source/blender/blenlib/intern/lasso.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/lasso.c	2013-09-01 03:37:45 UTC (rev 59697)
+++ trunk/blender/source/blender/blenlib/intern/lasso.c	2013-09-01 03:43:10 UTC (rev 59698)
@@ -34,12 +34,13 @@
 
 #include "BLI_math.h"
 #include "BLI_rect.h"
+#include "BLI_strict_flags.h"
 
 #include "BLI_lasso.h" /* own include */
 
-void BLI_lasso_boundbox(rcti *rect, const int mcords[][2], const short moves)
+void BLI_lasso_boundbox(rcti *rect, const int mcords[][2], const unsigned int moves)
 {
-	short a;
+	unsigned int a;
 
 	rect->xmin = rect->xmax = mcords[0][0];
 	rect->ymin = rect->ymax = mcords[0][1];
@@ -53,11 +54,11 @@
 }
 
 
-bool BLI_lasso_is_point_inside(const int mcords[][2], const short moves,
+bool BLI_lasso_is_point_inside(const int mcords[][2], const unsigned int moves,
                                const int sx, const int sy,
                                const int error_value)
 {
-	if (sx == error_value) {
+	if (sx == error_value || moves == 0) {
 		return false;
 	}
 	else {
@@ -67,14 +68,14 @@
 }
 
 /* edge version for lasso select. we assume boundbox check was done */
-bool BLI_lasso_is_edge_inside(const int mcords[][2], const short moves,
+bool BLI_lasso_is_edge_inside(const int mcords[][2], const unsigned int moves,
                               int x0, int y0, int x1, int y1,
                               const int error_value)
 {
 	int v1[2], v2[2];
-	int a;
+	unsigned int a;
 
-	if (x0 == error_value || x1 == error_value) {
+	if (x0 == error_value || x1 == error_value || moves == 0) {
 		return false;
 	}
 

Modified: trunk/blender/source/blender/blenlib/intern/quadric.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/quadric.c	2013-09-01 03:37:45 UTC (rev 59697)
+++ trunk/blender/source/blender/blenlib/intern/quadric.c	2013-09-01 03:43:10 UTC (rev 59698)
@@ -35,6 +35,8 @@
 //#include <string.h>
 
 #include "BLI_math.h"
+#include "BLI_strict_flags.h"
+
 #include "BLI_quadric.h"  /* own include */
 
 




More information about the Bf-blender-cvs mailing list