From: Matthew Fernandez Date: Mon, 26 Dec 2022 21:18:48 +0000 (-0800) Subject: ortho: track number of rectangles as a 'size_t' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d642b8980f71d1adf6f935f905cc58e0682f9eab;p=graphviz ortho: track number of rectangles as a 'size_t' Squashes a -Wconversion warning. --- diff --git a/lib/ortho/maze.c b/lib/ortho/maze.c index 818ff90de..bee24a4db 100644 --- a/lib/ortho/maze.c +++ b/lib/ortho/maze.c @@ -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); diff --git a/lib/ortho/partition.c b/lib/ortho/partition.c index 3e9cb0e97..89ad809de 100644 --- a/lib/ortho/partition.c +++ b/lib/ortho/partition.c @@ -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)); diff --git a/lib/ortho/partition.h b/lib/ortho/partition.h index 58960b3cc..bccfa7e37 100644 --- a/lib/ortho/partition.h +++ b/lib/ortho/partition.h @@ -16,6 +16,7 @@ #pragma once #include +#include /** * @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);