shithub: puzzles

Download patch

ref: 88358f064351e867c73e46783a239265ff9fef7a
parent: d204978391141a68b338732ce24271402392534f
author: Simon Tatham <anakin@pobox.com>
date: Mon Sep 13 07:04:59 EDT 2021

Add 'const' to the draw_polygon coords array parameter.

Thanks to Mouse for spotting that it was missing.

--- a/devel.but
+++ b/devel.but
@@ -1935,7 +1935,7 @@
 
 \S{drawing-draw-polygon} \cw{draw_polygon()}
 
-\c void draw_polygon(drawing *dr, int *coords, int npoints,
+\c void draw_polygon(drawing *dr, const int *coords, int npoints,
 \c                   int fillcolour, int outlinecolour);
 
 Draws an outlined or filled polygon in the puzzle window.
@@ -2497,7 +2497,7 @@
 
 \S{drawingapi-draw-polygon} \cw{draw_polygon()}
 
-\c void (*draw_polygon)(void *handle, int *coords, int npoints,
+\c void (*draw_polygon)(void *handle, const int *coords, int npoints,
 \c                      int fillcolour, int outlinecolour);
 
 This function behaves exactly like the back end \cw{draw_polygon()}
--- a/drawing.c
+++ b/drawing.c
@@ -117,7 +117,7 @@
     }
 }
 
-void draw_polygon(drawing *dr, int *coords, int npoints,
+void draw_polygon(drawing *dr, const int *coords, int npoints,
                   int fillcolour, int outlinecolour)
 {
     dr->api->draw_polygon(dr->handle, coords, npoints, fillcolour,
--- a/gtk.c
+++ b/gtk.c
@@ -571,7 +571,7 @@
     cairo_restore(fe->cr);
 }
 
-static void do_draw_poly(frontend *fe, int *coords, int npoints,
+static void do_draw_poly(frontend *fe, const int *coords, int npoints,
 			 int fillcolour, int outlinecolour)
 {
     int i;
@@ -832,7 +832,7 @@
 			       save.join_style);
 }
 
-static void do_draw_poly(frontend *fe, int *coords, int npoints,
+static void do_draw_poly(frontend *fe, const int *coords, int npoints,
 			 int fillcolour, int outlinecolour)
 {
     GdkPoint *points = snewn(npoints, GdkPoint);
@@ -1206,7 +1206,7 @@
     do_draw_thick_line(fe, thickness, x1, y1, x2, y2);
 }
 
-void gtk_draw_poly(void *handle, int *coords, int npoints,
+void gtk_draw_poly(void *handle, const int *coords, int npoints,
 		   int fillcolour, int outlinecolour)
 {
     frontend *fe = (frontend *)handle;
--- a/nullfe.c
+++ b/nullfe.c
@@ -15,7 +15,7 @@
 void draw_line(drawing *dr, int x1, int y1, int x2, int y2, int colour) {}
 void draw_thick_line(drawing *dr, float thickness,
 		     float x1, float y1, float x2, float y2, int colour) {}
-void draw_polygon(drawing *dr, int *coords, int npoints,
+void draw_polygon(drawing *dr, const int *coords, int npoints,
                   int fillcolour, int outlinecolour) {}
 void draw_circle(drawing *dr, int cx, int cy, int radius,
                  int fillcolour, int outlinecolour) {}
--- a/osx.m
+++ b/osx.m
@@ -1344,7 +1344,7 @@
 /*
  * Drawing routines called by the midend.
  */
-static void osx_draw_polygon(void *handle, int *coords, int npoints,
+static void osx_draw_polygon(void *handle, const int *coords, int npoints,
 			     int fillcolour, int outlinecolour)
 {
     frontend *fe = (frontend *)handle;
--- a/ps.c
+++ b/ps.c
@@ -157,7 +157,7 @@
     ps_stroke(ps, colour);
 }
 
-static void ps_draw_polygon(void *handle, int *coords, int npoints,
+static void ps_draw_polygon(void *handle, const int *coords, int npoints,
 			    int fillcolour, int outlinecolour)
 {
     psdata *ps = (psdata *)handle;
--- a/puzzles.h
+++ b/puzzles.h
@@ -248,7 +248,7 @@
                int align, int colour, const char *text);
 void draw_rect(drawing *dr, int x, int y, int w, int h, int colour);
 void draw_line(drawing *dr, int x1, int y1, int x2, int y2, int colour);
-void draw_polygon(drawing *dr, int *coords, int npoints,
+void draw_polygon(drawing *dr, const int *coords, int npoints,
                   int fillcolour, int outlinecolour);
 void draw_circle(drawing *dr, int cx, int cy, int radius,
                  int fillcolour, int outlinecolour);
@@ -700,7 +700,7 @@
     void (*draw_rect)(void *handle, int x, int y, int w, int h, int colour);
     void (*draw_line)(void *handle, int x1, int y1, int x2, int y2,
 		      int colour);
-    void (*draw_polygon)(void *handle, int *coords, int npoints,
+    void (*draw_polygon)(void *handle, const int *coords, int npoints,
 			 int fillcolour, int outlinecolour);
     void (*draw_circle)(void *handle, int cx, int cy, int radius,
 			int fillcolour, int outlinecolour);
--- a/windows.c
+++ b/windows.c
@@ -627,7 +627,7 @@
     win_reset_pen(fe);
 }
 
-static void win_draw_polygon(void *handle, int *coords, int npoints,
+static void win_draw_polygon(void *handle, const int *coords, int npoints,
 			     int fillcolour, int outlinecolour)
 {
     frontend *fe = (frontend *)handle;