cmwind: use 'const' with readonly data

This then required a cascade of function APIs to also now receive
const arguments.

This reduces the .data segment use of this module.
This commit is contained in:
Darryl L. Miles 2024-10-04 11:33:56 +01:00 committed by Tim Edwards
parent 34038ee687
commit 6b4d409d74
3 changed files with 17 additions and 17 deletions

View File

@ -143,8 +143,8 @@ cmwButtonDown(
Point *p,
int button)
{
ColorBar *cb;
ColorPump *cp;
const ColorBar *cb;
const ColorPump *cp;
Point surfacePoint;
int x;
double dx;
@ -598,8 +598,8 @@ cmwRedisplayFunc(
* color bars in the window.
*/
{
ColorBar *cb;
ColorPump *cp;
const ColorBar *cb;
const ColorPump *cp;
Rect screenR;
CMWclientRec *cr = (CMWclientRec *) w->w_clientData;
@ -649,7 +649,7 @@ CMWCheckWritten(void)
{
bool indx;
char *prompt;
static char *(yesno[]) = {"no", "yes", NULL};
static const char * const (yesno[]) = {"no", "yes", NULL};
if (!cmwModified) return TRUE;
prompt = TxPrintString("The color map has been modified.\n"

View File

@ -89,7 +89,7 @@ extern void CMWundoInit(void);
* which pump is hit and which mouse button is used to hit it.
*/
ColorBar colorBars[] =
const ColorBar const colorBars[] =
{
{"Red", CB_RED, STYLE_RED, {{ 2000, 8000}, {10000, 9000}},
{{ 2000, 9500}, {10000, 10500}}},
@ -106,7 +106,7 @@ ColorBar colorBars[] =
{0}
};
ColorPump colorPumps[] =
const ColorPump const colorPumps[] =
{
{CB_RED, -.0078, {{ 500, 8000}, { 1500, 9000}}},
{CB_RED, .0078, {{10500, 8000}, {11500, 9000}}},
@ -123,13 +123,13 @@ ColorPump colorPumps[] =
{-1}
};
Rect cmwCurrentColorArea = {{6000, 12000}, {18000, 15000}};
Rect cmwCurrentColorTextBox = {{6000, 15500}, {18000, 16500}};
char *cmwCurrentColorText = "Color Being Edited";
const Rect cmwCurrentColorArea = {{6000, 12000}, {18000, 15000}};
const Rect cmwCurrentColorTextBox = {{6000, 15500}, {18000, 16500}};
const char * const cmwCurrentColorText = "Color Being Edited";
/* Bounding rectangle for entire window */
Rect colorWindowRect = {{0, 1500}, {24000, 17000}};
const Rect colorWindowRect = {{0, 1500}, {24000, 17000}};
/*
* ----------------------------------------------------------------------------
@ -250,8 +250,8 @@ CMWredisplay(
Rect *clipArea) /* An area on the screen to clip to. */
{
CMWclientRec *cr;
ColorBar *cb;
ColorPump *cp;
const ColorBar *cb;
const ColorPump *cp;
Rect rect, screenR;
Point screenP;
double values[6], x;

View File

@ -69,11 +69,11 @@ typedef struct
extern void CMWloadWindow(MagWindow *, int);
extern void CMWcommand(MagWindow *, TxCommand *);
extern Rect colorWindowRect;
extern const Rect colorWindowRect;
extern WindClient CMWclientID;
extern ColorBar colorBars[];
extern ColorPump colorPumps[];
extern Rect cmwCurrentColorArea;
extern const ColorBar colorBars[];
extern const ColorPump colorPumps[];
extern const Rect cmwCurrentColorArea;
extern void cmwUndoColor(int, int, int, int, int, int, int);
extern bool CMWCheckWritten(void);