Skip to content

Commit

Permalink
cmwind: use 'const' with readonly data
Browse files Browse the repository at this point in the history
This then required a cascade of function APIs to also now receive
const arguments.

This reduces the .data segment use of this module.
  • Loading branch information
dlmiles authored and RTimothyEdwards committed Jan 4, 2025
1 parent 34038ee commit 6b4d409
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions cmwind/CMWcmmnds.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions cmwind/CMWmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}}},
Expand All @@ -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}}},
Expand All @@ -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}};

/*
* ----------------------------------------------------------------------------
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions cmwind/cmwind.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 6b4d409

Please sign in to comment.