diff options
| author | Simon Tatham <anakin@pobox.com> | 2017-10-01 13:53:24 +0100 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2017-10-01 16:34:41 +0100 |
| commit | b3243d75043cf1d70beb88d2a36eaebfe85c2c3f (patch) | |
| tree | ab6151e321465c172582ca064910665f055ceec9 /windows.c | |
| parent | de67801b0fd3dfa11777c1ef86cd617baf376b7b (diff) | |
| download | puzzles-b3243d75043cf1d70beb88d2a36eaebfe85c2c3f.zip puzzles-b3243d75043cf1d70beb88d2a36eaebfe85c2c3f.tar.gz puzzles-b3243d75043cf1d70beb88d2a36eaebfe85c2c3f.tar.bz2 puzzles-b3243d75043cf1d70beb88d2a36eaebfe85c2c3f.tar.xz | |
Return error messages as 'const char *', not 'char *'.
They're never dynamically allocated, and are almost always string
literals, so const is more appropriate.
Diffstat (limited to 'windows.c')
| -rw-r--r-- | windows.c | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -1002,7 +1002,7 @@ void print(frontend *fe) document *doc; midend *nme = NULL; /* non-interactive midend for bulk puzzle generation */ int i; - char *err = NULL; + const char *err = NULL; /* * Create our document structure and fill it up with puzzles. @@ -1586,7 +1586,7 @@ static midend *midend_for_new_game(frontend *fe, const game *cgame, midend_new_game(me); } else { FILE *fp; - char *err_param, *err_load; + const char *err_param, *err_load; /* * See if arg is a valid filename of a save game file. @@ -2103,7 +2103,8 @@ static config_item *frontend_get_config(frontend *fe, int which, } } -static char *frontend_set_config(frontend *fe, int which, config_item *cfg) +static const char *frontend_set_config( + frontend *fe, int which, config_item *cfg) { if (which < CFG_FRONTEND_SPECIFIC) { return midend_set_config(fe->me, which, cfg); @@ -2276,7 +2277,8 @@ static int CALLBACK ConfigDlgProc(HWND hwnd, UINT msg, */ if ((LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)) { if (LOWORD(wParam) == IDOK) { - char *err = frontend_set_config(fe, fe->cfg_which, fe->cfg); + const char *err = frontend_set_config( + fe, fe->cfg_which, fe->cfg); if (err) { MessageBox(hwnd, err, "Validation error", @@ -3015,7 +3017,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, break; case IDM_SOLVE: { - char *msg = midend_solve(fe->me); + const char *msg = midend_solve(fe->me); if (msg) MessageBox(hwnd, msg, "Unable to solve", MB_ICONERROR | MB_OK); @@ -3107,7 +3109,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, fclose(fp); } else { FILE *fp = fopen(filename, "r"); - char *err = NULL; + const char *err = NULL; + char *err_w = NULL; midend *me = fe->me; #ifdef COMBINED char *id_name; @@ -3135,7 +3138,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, "supported by this program"; } else { me = midend_for_new_game(fe, gamelist[i], NULL, - FALSE, FALSE, &err); + FALSE, FALSE, &err_w); + err = err_w; rewind(fp); /* for the actual load */ } sfree(id_name); @@ -3148,6 +3152,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, if (err) { MessageBox(hwnd, err, "Error", MB_ICONERROR|MB_OK); + sfree(err_w); break; } |