]> granicus.if.org Git - graphviz/commitdiff
ortho: track number of rectangles as a 'size_t'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 26 Dec 2022 21:18:48 +0000 (13:18 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 31 Dec 2022 23:34:34 +0000 (15:34 -0800)
Squashes a -Wconversion warning.

lib/ortho/maze.c
lib/ortho/partition.c
lib/ortho/partition.h

index 818ff90de446e3775546d86e7563482eab686257..bee24a4db08a2011d4435f12217e6cd9bd5da454 100644 (file)
@@ -56,9 +56,7 @@ char* post = "showpage\n";
 /// @brief dumps @ref maze::gcells and @ref maze::cells via rects to PostScript
 
 static void
-psdump (cell* gcells, int n_gcells, boxf BB, boxf* rects, int nrect)
-{
-    int i;
+psdump(cell *gcells, int n_gcells, boxf BB, boxf *rects, size_t nrect) {
     boxf bb;
     box absbb;
 
@@ -72,12 +70,12 @@ psdump (cell* gcells, int n_gcells, boxf BB, boxf* rects, int nrect)
 
     fprintf (stderr, "%f %f translate\n", 10-BB.LL.x, 10-BB.LL.y);
     fputs ("0 0 1 setrgbcolor\n", stderr);
-    for (i = 0; i < n_gcells; i++) {
+    for (int i = 0; i < n_gcells; i++) {
       bb = gcells[i].bb;
       fprintf (stderr, "%f %f %f %f node\n", bb.LL.x, bb.LL.y, bb.UR.x, bb.UR.y);
     }
     fputs ("0 0 0 setrgbcolor\n", stderr);
-    for (i = 0; i < nrect; i++) {
+    for (size_t i = 0; i < nrect; i++) {
       bb = rects[i];
       fprintf (stderr, "%f %f %f %f cell\n", bb.LL.x, bb.LL.y, bb.UR.x, bb.UR.y);
     }
@@ -468,7 +466,6 @@ maze *mkMaze(graph_t *g) {
     node_t* n;
     maze* mp = gv_alloc(sizeof(maze));
     boxf* rects;
-    int i, nrect;
     cell* cp;
     double w2, h2;
     boxf bb, BB;
@@ -499,6 +496,7 @@ maze *mkMaze(graph_t *g) {
     BB.LL.y -= MARGIN;
     BB.UR.x += MARGIN;
     BB.UR.y += MARGIN;
+    size_t nrect;
     rects = partition (mp->gcells, mp->ngcells, &nrect, BB);
 
 #ifdef DEBUG
@@ -506,7 +504,7 @@ maze *mkMaze(graph_t *g) {
 #endif
     mp->cells = gv_calloc(nrect, sizeof(cell));
     mp->ncells = nrect;
-    for (i = 0; i < nrect; i++) {
+    for (size_t i = 0; i < nrect; i++) {
        mp->cells[i].bb = rects[i];
     }
     free (rects);
index 3e9cb0e9725b6676773734cfd63a913a7931a7ba..89ad809de9c065c775b9afa23229d2102e46e9f0 100644 (file)
@@ -684,9 +684,7 @@ dumpSegs (segment_t* sg, int n)
 }
 #endif
 
-boxf*
-partition (cell* cells, int ncells, int* nrects, boxf bb)
-{
+boxf *partition(cell *cells, int ncells, size_t *nrects, boxf bb) {
     int nsegs = 4*(ncells+1);
     segment_t* segs = gv_calloc(nsegs + 1, sizeof(segment_t));
     int* permute = gv_calloc(nsegs + 1, sizeof(int));
index 58960b3cc70aa07c36238f710e6b25e2fdb501e6..bccfa7e37c7cdb6c73653035ff42bf8e9491e787 100644 (file)
@@ -16,6 +16,7 @@
 #pragma once
 
 #include <ortho/maze.h>
+#include <stddef.h>
 
 /**
  * @brief partitions space around cells (nodes) into rectangular tiles
@@ -25,4 +26,4 @@
  * @returns array of the tiles
  */
 
-boxf* partition(cell* cells, int ncells, int* nrects, boxf bb);
+boxf *partition(cell *cells, int ncells, size_t *nrects, boxf bb);