From 0186d78da9e83103eb80b3814d4de8031f29232f Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Thu, 16 Feb 2023 21:21:15 +0000 Subject: [PATCH] Mark many more function (and some objects) static I noticed commit db3b531e2cab765a00475054d2e9046c9d0437d3 in the history where Simon added a bunch of "static" qualifiers. That suggested that consistently marking internal functions "static" is desirable, so I tried a build using GCC's -Wmissing-declarations, which requires prior declaration (presumed to be in a header file) of all global functions. This commit makes the GTK build clean under GCC's -Wmissing-declarations. I've also adding "static" to a few obviously internal objects, but GCC doesn't complain about those so I certainly haven't got them all. --- dominosa.c | 2 +- gtk.c | 106 ++++++++++++++++++++++-------------------- latin.c | 4 +- magnets.c | 4 +- matching.c | 26 +++++------ penrose.c | 4 +- signpost.c | 2 +- sort.c | 4 +- tree234.c | 36 +++++++------- unfinished/numgame.c | 16 +++---- unfinished/separate.c | 16 +++---- unfinished/sokoban.c | 2 +- 12 files changed, 113 insertions(+), 109 deletions(-) diff --git a/dominosa.c b/dominosa.c index 61b345e..94e61b1 100644 --- a/dominosa.c +++ b/dominosa.c @@ -930,7 +930,7 @@ struct parity_findloop_ctx { int i; }; -int parity_neighbour(int vertex, void *vctx) +static int parity_neighbour(int vertex, void *vctx) { struct parity_findloop_ctx *ctx = (struct parity_findloop_ctx *)vctx; struct solver_placement *p; diff --git a/gtk.c b/gtk.c index a058775..0549f10 100644 --- a/gtk.c +++ b/gtk.c @@ -319,7 +319,7 @@ void frontend_default_colour(frontend *fe, float *output) output[0] = output[1] = output[2] = 0.9F; } -void gtk_status_bar(void *handle, const char *text) +static void gtk_status_bar(void *handle, const char *text) { frontend *fe = (frontend *)handle; @@ -1154,7 +1154,7 @@ static void align_and_draw_text(int index, int align, int x, int y, * The exported drawing functions. */ -void gtk_start_draw(void *handle) +static void gtk_start_draw(void *handle) { frontend *fe = (frontend *)handle; fe->bbox_l = fe->w; @@ -1164,20 +1164,21 @@ void gtk_start_draw(void *handle) setup_drawing(fe); } -void gtk_clip(void *handle, int x, int y, int w, int h) +static void gtk_clip(void *handle, int x, int y, int w, int h) { frontend *fe = (frontend *)handle; do_clip(fe, x, y, w, h); } -void gtk_unclip(void *handle) +static void gtk_unclip(void *handle) { frontend *fe = (frontend *)handle; do_unclip(fe); } -void gtk_draw_text(void *handle, int x, int y, int fonttype, int fontsize, - int align, int colour, const char *text) +static void gtk_draw_text(void *handle, int x, int y, int fonttype, + int fontsize, int align, int colour, + const char *text) { frontend *fe = (frontend *)handle; int i; @@ -1209,43 +1210,45 @@ void gtk_draw_text(void *handle, int x, int y, int fonttype, int fontsize, align_and_draw_text(fe, i, align, x, y, text); } -void gtk_draw_rect(void *handle, int x, int y, int w, int h, int colour) +static void gtk_draw_rect(void *handle, int x, int y, int w, int h, int colour) { frontend *fe = (frontend *)handle; fe->dr_api->set_colour(fe, colour); do_draw_rect(fe, x, y, w, h); } -void gtk_draw_line(void *handle, int x1, int y1, int x2, int y2, int colour) +static void gtk_draw_line(void *handle, int x1, int y1, int x2, int y2, + int colour) { frontend *fe = (frontend *)handle; fe->dr_api->set_colour(fe, colour); do_draw_line(fe, x1, y1, x2, y2); } -void gtk_draw_thick_line(void *handle, float thickness, - float x1, float y1, float x2, float y2, int colour) +static void gtk_draw_thick_line(void *handle, float thickness, + float x1, float y1, float x2, float y2, + int colour) { frontend *fe = (frontend *)handle; fe->dr_api->set_colour(fe, colour); do_draw_thick_line(fe, thickness, x1, y1, x2, y2); } -void gtk_draw_poly(void *handle, const int *coords, int npoints, - int fillcolour, int outlinecolour) +static void gtk_draw_poly(void *handle, const int *coords, int npoints, + int fillcolour, int outlinecolour) { frontend *fe = (frontend *)handle; do_draw_poly(fe, coords, npoints, fillcolour, outlinecolour); } -void gtk_draw_circle(void *handle, int cx, int cy, int radius, - int fillcolour, int outlinecolour) +static void gtk_draw_circle(void *handle, int cx, int cy, int radius, + int fillcolour, int outlinecolour) { frontend *fe = (frontend *)handle; do_draw_circle(fe, cx, cy, radius, fillcolour, outlinecolour); } -blitter *gtk_blitter_new(void *handle, int w, int h) +static blitter *gtk_blitter_new(void *handle, int w, int h) { blitter *bl = snew(blitter); setup_blitter(bl, w, h); @@ -1254,13 +1257,13 @@ blitter *gtk_blitter_new(void *handle, int w, int h) return bl; } -void gtk_blitter_free(void *handle, blitter *bl) +static void gtk_blitter_free(void *handle, blitter *bl) { teardown_blitter(bl); sfree(bl); } -void gtk_blitter_save(void *handle, blitter *bl, int x, int y) +static void gtk_blitter_save(void *handle, blitter *bl, int x, int y) { frontend *fe = (frontend *)handle; do_blitter_save(fe, bl, x, y); @@ -1268,7 +1271,7 @@ void gtk_blitter_save(void *handle, blitter *bl, int x, int y) bl->y = y; } -void gtk_blitter_load(void *handle, blitter *bl, int x, int y) +static void gtk_blitter_load(void *handle, blitter *bl, int x, int y) { frontend *fe = (frontend *)handle; if (x == BLITTER_FROMSAVED && y == BLITTER_FROMSAVED) { @@ -1278,7 +1281,7 @@ void gtk_blitter_load(void *handle, blitter *bl, int x, int y) do_blitter_load(fe, bl, x, y); } -void gtk_draw_update(void *handle, int x, int y, int w, int h) +static void gtk_draw_update(void *handle, int x, int y, int w, int h) { frontend *fe = (frontend *)handle; if (fe->bbox_l > x ) fe->bbox_l = x ; @@ -1287,7 +1290,7 @@ void gtk_draw_update(void *handle, int x, int y, int w, int h) if (fe->bbox_d < y+h) fe->bbox_d = y+h; } -void gtk_end_draw(void *handle) +static void gtk_end_draw(void *handle) { frontend *fe = (frontend *)handle; @@ -1311,7 +1314,8 @@ void gtk_end_draw(void *handle) } #ifdef USE_PANGO -char *gtk_text_fallback(void *handle, const char *const *strings, int nstrings) +static char *gtk_text_fallback(void *handle, const char *const *strings, + int nstrings) { /* * We assume Pango can cope with any UTF-8 likely to be emitted @@ -1322,18 +1326,18 @@ char *gtk_text_fallback(void *handle, const char *const *strings, int nstrings) #endif #ifdef USE_PRINTING -void gtk_begin_doc(void *handle, int pages) +static void gtk_begin_doc(void *handle, int pages) { frontend *fe = (frontend *)handle; gtk_print_operation_set_n_pages(fe->printop, pages); } -void gtk_begin_page(void *handle, int number) +static void gtk_begin_page(void *handle, int number) { } -void gtk_begin_puzzle(void *handle, float xm, float xc, - float ym, float yc, int pw, int ph, float wmm) +static void gtk_begin_puzzle(void *handle, float xm, float xc, + float ym, float yc, int pw, int ph, float wmm) { frontend *fe = (frontend *)handle; double ppw, pph, pox, poy, dpmmx, dpmmy; @@ -1371,27 +1375,27 @@ void gtk_begin_puzzle(void *handle, float xm, float xc, fe->hatchspace = 1.0 * pw / wmm; } -void gtk_end_puzzle(void *handle) +static void gtk_end_puzzle(void *handle) { frontend *fe = (frontend *)handle; cairo_restore(fe->cr); } -void gtk_end_page(void *handle, int number) +static void gtk_end_page(void *handle, int number) { } -void gtk_end_doc(void *handle) +static void gtk_end_doc(void *handle) { } -void gtk_line_width(void *handle, float width) +static void gtk_line_width(void *handle, float width) { frontend *fe = (frontend *)handle; cairo_set_line_width(fe->cr, width); } -void gtk_line_dotted(void *handle, bool dotted) +static void gtk_line_dotted(void *handle, bool dotted) { frontend *fe = (frontend *)handle; @@ -1404,7 +1408,7 @@ void gtk_line_dotted(void *handle, bool dotted) } #endif /* USE_PRINTING */ -const struct internal_drawing_api internal_drawing = { +static const struct internal_drawing_api internal_drawing = { draw_set_colour, #ifdef USE_CAIRO do_draw_fill, @@ -1413,14 +1417,14 @@ const struct internal_drawing_api internal_drawing = { }; #ifdef USE_CAIRO -const struct internal_drawing_api internal_printing = { +static const struct internal_drawing_api internal_printing = { print_set_colour, do_print_fill, do_print_fill_preserve, }; #endif -const struct drawing_api gtk_drawing = { +static const struct drawing_api gtk_drawing = { gtk_draw_text, gtk_draw_rect, gtk_draw_line, @@ -1798,8 +1802,8 @@ static void align_label(GtkLabel *label, double x, double y) } #if GTK_CHECK_VERSION(3,0,0) -bool message_box(GtkWidget *parent, const char *title, const char *msg, - bool centre, int type) +static bool message_box(GtkWidget *parent, const char *title, const char *msg, + bool centre, int type) { GtkWidget *window; gint ret; @@ -1893,7 +1897,7 @@ bool message_box(GtkWidget *parent, const char *title, const char *msg, } #endif /* GTK_CHECK_VERSION(3,0,0) */ -void error_box(GtkWidget *parent, const char *msg) +static void error_box(GtkWidget *parent, const char *msg) { message_box(parent, "Error", msg, false, MB_OK); } @@ -2414,7 +2418,7 @@ static void set_selection(frontend *fe, GdkAtom selection) } } -void write_clip(frontend *fe, char *data) +static void write_clip(frontend *fe, char *data) { if (fe->paste_data) sfree(fe->paste_data); @@ -2426,16 +2430,16 @@ void write_clip(frontend *fe, char *data) set_selection(fe, GDK_SELECTION_CLIPBOARD); } -void selection_get(GtkWidget *widget, GtkSelectionData *seldata, - guint info, guint time_stamp, gpointer data) +static void selection_get(GtkWidget *widget, GtkSelectionData *seldata, + guint info, guint time_stamp, gpointer data) { frontend *fe = (frontend *)data; gtk_selection_data_set(seldata, gtk_selection_data_get_target(seldata), 8, fe->paste_data, fe->paste_data_len); } -gint selection_clear(GtkWidget *widget, GdkEventSelection *seldata, - gpointer data) +static gint selection_clear(GtkWidget *widget, GdkEventSelection *seldata, + gpointer data) { frontend *fe = (frontend *)data; @@ -2533,7 +2537,7 @@ static char *file_selector(frontend *fe, const char *title, bool save) #endif #ifdef USE_PRINTING -GObject *create_print_widget(GtkPrintOperation *print, gpointer data) +static GObject *create_print_widget(GtkPrintOperation *print, gpointer data) { GtkLabel *count_label, *width_label, *height_label, *scale_llabel, *scale_rlabel; @@ -2674,8 +2678,8 @@ GObject *create_print_widget(GtkPrintOperation *print, gpointer data) return G_OBJECT(grid); } -void apply_print_widget(GtkPrintOperation *print, - GtkWidget *widget, gpointer data) +static void apply_print_widget(GtkPrintOperation *print, + GtkWidget *widget, gpointer data) { frontend *fe = (frontend *)data; @@ -2698,8 +2702,8 @@ void apply_print_widget(GtkPrintOperation *print, } } -void print_begin(GtkPrintOperation *printop, - GtkPrintContext *context, gpointer data) +static void print_begin(GtkPrintOperation *printop, + GtkPrintContext *context, gpointer data) { frontend *fe = (frontend *)data; midend *nme = NULL; /* non-interactive midend for bulk puzzle generation */ @@ -2750,16 +2754,16 @@ void print_begin(GtkPrintOperation *printop, document_begin(fe->doc, fe->print_dr); } -void draw_page(GtkPrintOperation *printop, - GtkPrintContext *context, - gint page_nr, gpointer data) +static void draw_page(GtkPrintOperation *printop, + GtkPrintContext *context, + gint page_nr, gpointer data) { frontend *fe = (frontend *)data; document_print_page(fe->doc, fe->print_dr, page_nr); } -void print_end(GtkPrintOperation *printop, - GtkPrintContext *context, gpointer data) +static void print_end(GtkPrintOperation *printop, + GtkPrintContext *context, gpointer data) { frontend *fe = (frontend *)data; diff --git a/latin.c b/latin.c index 59f306d..2b4848f 100644 --- a/latin.c +++ b/latin.c @@ -1352,7 +1352,7 @@ static void gen(int order, random_state *rs, int debug) sfree(sq); } -void test_soak(int order, random_state *rs) +static void test_soak(int order, random_state *rs) { digit *sq; int n = 0; @@ -1375,7 +1375,7 @@ void test_soak(int order, random_state *rs) } } -void usage_exit(const char *msg) +static void usage_exit(const char *msg) { if (msg) fprintf(stderr, "%s: %s\n", quis, msg); diff --git a/magnets.c b/magnets.c index 0cd9adb..1f8ec2c 100644 --- a/magnets.c +++ b/magnets.c @@ -2492,11 +2492,11 @@ const struct game thegame = { const char *quis = NULL; bool csv = false; -void usage(FILE *out) { +static void usage(FILE *out) { fprintf(out, "usage: %s [-v] [--print] |\n", quis); } -void doprint(game_state *state) +static void doprint(game_state *state) { char *fmt = game_text_format(state); printf("%s", fmt); diff --git a/matching.c b/matching.c index 5aecce8..27b288f 100644 --- a/matching.c +++ b/matching.c @@ -368,13 +368,13 @@ static void matching_witness(void *scratchv, int nl, int nr, int *witness) #include "tree234.h" -int nl, nr, count; -int **adjlists, *adjsizes; -int *adjdata, *outl, *outr, *witness; -void *scratch; -random_state *rs; +static int nl, nr, count; +static int **adjlists, *adjsizes; +static int *adjdata, *outl, *outr, *witness; +static void *scratch; +static random_state *rs; -void allocate(int nl_, int nr_, int maxedges) +static void allocate(int nl_, int nr_, int maxedges) { nl = nl_; nr = nr_; @@ -387,7 +387,7 @@ void allocate(int nl_, int nr_, int maxedges) scratch = smalloc(matching_scratch_size(nl, nr)); } -void deallocate(void) +static void deallocate(void) { sfree(adjlists); sfree(adjsizes); @@ -398,7 +398,7 @@ void deallocate(void) sfree(scratch); } -void find_and_check_matching(void) +static void find_and_check_matching(void) { int i, j, k; @@ -454,14 +454,14 @@ struct nodename { int index; }; -int compare_nodes(void *av, void *bv) +static int compare_nodes(void *av, void *bv) { const struct nodename *a = (const struct nodename *)av; const struct nodename *b = (const struct nodename *)bv; return strcmp(a->name, b->name); } -int node_index(tree234 *n2i, tree234 *i2n, const char *name) +static int node_index(tree234 *n2i, tree234 *i2n, const char *name) { struct nodename *nn, *nn_prev; char *namedup = dupstr(name); @@ -485,7 +485,7 @@ struct edge { int L, R; }; -int compare_edges(void *av, void *bv) +static int compare_edges(void *av, void *bv) { const struct edge *a = (const struct edge *)av; const struct edge *b = (const struct edge *)bv; @@ -496,7 +496,7 @@ int compare_edges(void *av, void *bv) return 0; } -void matching_from_user_input(FILE *fp, const char *filename) +static void matching_from_user_input(FILE *fp, const char *filename) { tree234 *Ln2i, *Li2n, *Rn2i, *Ri2n, *edges; char *line = NULL; @@ -576,7 +576,7 @@ void matching_from_user_input(FILE *fp, const char *filename) deallocate(); } -void test_subsets(void) +static void test_subsets(void) { int b = 8; int n = 1 << b; diff --git a/penrose.c b/penrose.c index 4015ef7..b056ae5 100644 --- a/penrose.c +++ b/penrose.c @@ -512,7 +512,7 @@ void penrose_calculate_size(int which, int tilesize, int w, int h, int show_recursion = 0; int ntiles, nfinal; -int test_cb(penrose_state *state, vector *vs, int n, int depth) +static int test_cb(penrose_state *state, vector *vs, int n, int depth) { int i, xoff = 0, yoff = 0; double l = penrose_side_length(state->start_size, depth); @@ -542,7 +542,7 @@ int test_cb(penrose_state *state, vector *vs, int n, int depth) return 0; } -void usage_exit(void) +static void usage_exit(void) { fprintf(stderr, "Usage: penrose-test [--recursion] P2|P3 SIZE DEPTH\n"); exit(1); diff --git a/signpost.c b/signpost.c index 17557a3..c74d9d4 100644 --- a/signpost.c +++ b/signpost.c @@ -2321,7 +2321,7 @@ const struct game thegame = { const char *quis = NULL; int verbose = 0; -void usage(FILE *out) { +static void usage(FILE *out) { fprintf(out, "usage: %s [--stdin] [--soak] [--seed SEED] |\n", quis); } diff --git a/sort.c b/sort.c index d1897b6..2e20cac 100644 --- a/sort.c +++ b/sort.c @@ -93,14 +93,14 @@ void arraysort_fn(void *array, size_t nmemb, size_t size, #include #include -int testcmp(const void *av, const void *bv, void *ctx) +static int testcmp(const void *av, const void *bv, void *ctx) { int a = *(const int *)av, b = *(const int *)bv; const int *keys = (const int *)ctx; return keys[a] < keys[b] ? -1 : keys[a] > keys[b] ? +1 : 0; } -int resetcmp(const void *av, const void *bv) +static int resetcmp(const void *av, const void *bv) { int a = *(const int *)av, b = *(const int *)bv; return a < b ? -1 : a > b ? +1 : 0; diff --git a/tree234.c b/tree234.c index 1cdae9f..db33ed4 100644 --- a/tree234.c +++ b/tree234.c @@ -1491,7 +1491,7 @@ tree234 *copytree234(tree234 *t, copyfn234 copyfn, void *copyfnstate) { /* * Error reporting function. */ -void error(const char *fmt, ...) { +static void error(const char *fmt, ...) { va_list ap; printf("ERROR: "); va_start(ap, fmt); @@ -1517,7 +1517,7 @@ typedef struct { char **levels; } dispctx; -int dispnode(node234 *n, int level, dispctx *ctx) { +static int dispnode(node234 *n, int level, dispctx *ctx) { if (level == 0) { int xpos = strlen(ctx->levels[0]); int len; @@ -1614,7 +1614,7 @@ int dispnode(node234 *n, int level, dispctx *ctx) { } } -void disptree(tree234 *t) { +static void disptree(tree234 *t) { dispctx ctx; char *leveldata; int width = count234(t); @@ -1646,8 +1646,8 @@ typedef struct { int elemcount; } chkctx; -int chknode(chkctx *ctx, int level, node234 *node, - void *lowbound, void *highbound) { +static int chknode(chkctx *ctx, int level, node234 *node, + void *lowbound, void *highbound) { int nkids, nelems; int i; int count; @@ -1756,7 +1756,7 @@ int chknode(chkctx *ctx, int level, node234 *node, return count; } -void verifytree(tree234 *tree, void **array, int arraylen) { +static void verifytree(tree234 *tree, void **array, int arraylen) { chkctx ctx; int i; void *p; @@ -1795,9 +1795,9 @@ void verifytree(tree234 *tree, void **array, int arraylen) { ctx.elemcount, i); } } -void verify(void) { verifytree(tree, array, arraylen); } +static void verify(void) { verifytree(tree, array, arraylen); } -void internal_addtest(void *elem, int index, void *realret) { +static void internal_addtest(void *elem, int index, void *realret) { int i, j; void *retval; @@ -1822,7 +1822,7 @@ void internal_addtest(void *elem, int index, void *realret) { verify(); } -void addtest(void *elem) { +static void addtest(void *elem) { int i; void *realret; @@ -1840,7 +1840,7 @@ void addtest(void *elem) { internal_addtest(elem, i, realret); } -void addpostest(void *elem, int i) { +static void addpostest(void *elem, int i) { void *realret; realret = addpos234(tree, elem, i); @@ -1848,7 +1848,7 @@ void addpostest(void *elem, int i) { internal_addtest(elem, i, realret); } -void delpostest(int i) { +static void delpostest(int i) { int index = i; void *elem = array[i], *ret; @@ -1871,7 +1871,7 @@ void delpostest(int i) { verify(); } -void deltest(void *elem) { +static void deltest(void *elem) { int i; i = 0; @@ -1890,19 +1890,19 @@ void deltest(void *elem) { * given in ANSI C99 draft N869. It assumes `unsigned' is 32 bits; * change it if not. */ -int randomnumber(unsigned *seed) { +static int randomnumber(unsigned *seed) { *seed *= 1103515245; *seed += 12345; return ((*seed) / 65536) % 32768; } -int mycmp(void *av, void *bv) { +static int mycmp(void *av, void *bv) { char const *a = (char const *)av; char const *b = (char const *)bv; return strcmp(a, b); } -const char *const strings_init[] = { +static const char *const strings_init[] = { "0", "2", "3", "I", "K", "d", "H", "J", "Q", "N", "n", "q", "j", "i", "7", "G", "F", "D", "b", "x", "g", "B", "e", "v", "V", "T", "f", "E", "S", "8", "A", "k", "X", "p", "C", "R", "a", "o", "r", "O", "Z", "u", @@ -1924,9 +1924,9 @@ const char *const strings_init[] = { }; #define NSTR lenof(strings_init) -char *strings[NSTR]; +static char *strings[NSTR]; -void findtest(void) { +static void findtest(void) { static const int rels[] = { REL234_EQ, REL234_GE, REL234_LE, REL234_LT, REL234_GT }; @@ -2015,7 +2015,7 @@ void findtest(void) { } } -void splittest(tree234 *tree, void **array, int arraylen) { +static void splittest(tree234 *tree, void **array, int arraylen) { int i; tree234 *tree3, *tree4; for (i = 0; i <= arraylen; i++) { diff --git a/unfinished/numgame.c b/unfinished/numgame.c index e6dc03a..b819a93 100644 --- a/unfinished/numgame.c +++ b/unfinished/numgame.c @@ -987,11 +987,11 @@ static void free_sets(struct sets *s) /* * Print a text formula for producing a given output. */ -void print_recurse(struct sets *s, struct set *ss, int pathindex, int index, - int priority, int assoc, int child); -void print_recurse_inner(struct sets *s, struct set *ss, - struct ancestor *a, int pathindex, int index, - int priority, int assoc, int child) +static void print_recurse(struct sets *s, struct set *ss, int pathindex, + int index, int priority, int assoc, int child); +static void print_recurse_inner(struct sets *s, struct set *ss, + struct ancestor *a, int pathindex, int index, + int priority, int assoc, int child) { if (a->prev && index != a->pr) { int pi; @@ -1066,8 +1066,8 @@ void print_recurse_inner(struct sets *s, struct set *ss, printf("/%d", ss->numbers[2*index+1]); } } -void print_recurse(struct sets *s, struct set *ss, int pathindex, int index, - int priority, int assoc, int child) +static void print_recurse(struct sets *s, struct set *ss, int pathindex, + int index, int priority, int assoc, int child) { if (!ss->a.prev || pathindex < ss->a.prev->npaths) { print_recurse_inner(s, ss, &ss->a, pathindex, @@ -1085,7 +1085,7 @@ void print_recurse(struct sets *s, struct set *ss, int pathindex, int index, } } } -void print(int pathindex, struct sets *s, struct output *o) +static void print(int pathindex, struct sets *s, struct output *o) { print_recurse(s, o->set, pathindex, o->index, 0, 0, 0); } diff --git a/unfinished/separate.c b/unfinished/separate.c index 1a8edc6..9ffa632 100644 --- a/unfinished/separate.c +++ b/unfinished/separate.c @@ -215,7 +215,7 @@ struct solver_scratch { int *tmp; }; -struct solver_scratch *solver_scratch_new(int w, int h, int k) +static struct solver_scratch *solver_scratch_new(int w, int h, int k) { int wh = w*h; struct solver_scratch *sc = snew(struct solver_scratch); @@ -233,7 +233,7 @@ struct solver_scratch *solver_scratch_new(int w, int h, int k) return sc; } -void solver_scratch_free(struct solver_scratch *sc) +static void solver_scratch_free(struct solver_scratch *sc) { sfree(sc->dsf); sfree(sc->size); @@ -243,7 +243,7 @@ void solver_scratch_free(struct solver_scratch *sc) sfree(sc); } -void solver_connect(struct solver_scratch *sc, int yx1, int yx2) +static void solver_connect(struct solver_scratch *sc, int yx1, int yx2) { int w = sc->w, h = sc->h, k = sc->k; int wh = w*h; @@ -297,7 +297,7 @@ void solver_connect(struct solver_scratch *sc, int yx1, int yx2) sc->disconnect[i*wh+yx2]); } -void solver_disconnect(struct solver_scratch *sc, int yx1, int yx2) +static void solver_disconnect(struct solver_scratch *sc, int yx1, int yx2) { int w = sc->w, h = sc->h; int wh = w*h; @@ -316,7 +316,7 @@ void solver_disconnect(struct solver_scratch *sc, int yx1, int yx2) sc->disconnect[yx2*wh+yx1] = true; } -void solver_init(struct solver_scratch *sc) +static void solver_init(struct solver_scratch *sc) { int w = sc->w, h = sc->h; int wh = w*h; @@ -332,8 +332,8 @@ void solver_init(struct solver_scratch *sc) memset(sc->disconnect, 0, wh*wh * sizeof(bool)); } -int solver_attempt(struct solver_scratch *sc, const unsigned char *grid, - bool *gen_lock) +static int solver_attempt(struct solver_scratch *sc, const unsigned char *grid, + bool *gen_lock) { int w = sc->w, h = sc->h, k = sc->k; int wh = w*h; @@ -492,7 +492,7 @@ int solver_attempt(struct solver_scratch *sc, const unsigned char *grid, return 0; } -unsigned char *generate(int w, int h, int k, random_state *rs) +static unsigned char *generate(int w, int h, int k, random_state *rs) { int wh = w*h; int n = wh/k; diff --git a/unfinished/sokoban.c b/unfinished/sokoban.c index 26c957c..80596c2 100644 --- a/unfinished/sokoban.c +++ b/unfinished/sokoban.c @@ -957,7 +957,7 @@ struct game_drawstate { * subfunction. move_type() returns -1 for an illegal move, 0 for a * movement, and 1 for a push. */ -int move_type(const game_state *state, int dx, int dy) +static int move_type(const game_state *state, int dx, int dy) { int w = state->p.w, h = state->p.h; int px = state->px, py = state->py;