Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ti[GS]etClient() usage enforcement #387

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Ti[GS]etClient() usage enforcement
All naked access to `ti_client` now uses the function-like-macro
to encapsulate this action.  This macro existed before this just
makes all sites utilize it.

Added additional INT and PTR variants to remove the programmer
load on thinking about casing and casts polluting the point
of use.  So the use now looks cleaner.

Equivalent prototypes:

 void TiSetClient(Tile*, ClientData)
 void TiSetClientINT(Tile*, intptr_t) /* pointertype */
 void TiSetClientPTR(Tile*, void*)

 ClientData TiGetClient(Tile*)
 intptr_t TiGetClientINT(Tile*) /* pointertype */
 void *TiGetClientPTR(Tile*)
dlmiles committed Feb 21, 2025
commit d776adf1dc415d1353a228853167b4ce16667de9
10 changes: 5 additions & 5 deletions calma/CalmaWrite.c
Original file line number Diff line number Diff line change
@@ -117,8 +117,8 @@ extern void calmaRemoveDegenerate(BoundaryTop *blist);
#define GDS_PROCESSED 1

#define PUSHTILEC(tp) \
if ((tp)->ti_client == (ClientData) GDS_UNPROCESSED) { \
(tp)->ti_client = (ClientData) GDS_PENDING; \
if (TiGetClient(tp) == GDS_UNPROCESSED) { \
TiSetClientINT(tp, GDS_PENDING); \
STACKPUSH((ClientData) (tp), SegStack); \
}

@@ -2462,7 +2462,7 @@ calmaMergePaintFunc(
BoundaryTop *bounds = NULL;

/* Quick check for tiles that have already been processed */
if (tile->ti_client == (ClientData)GDS_PROCESSED) return 0;
if (TiGetClientINT(tile) == GDS_PROCESSED) return 0;

if (SegStack == (Stack *)NULL)
SegStack = StackNew(64);
@@ -2471,8 +2471,8 @@ calmaMergePaintFunc(
while (!StackEmpty(SegStack))
{
t = (Tile *) STACKPOP(SegStack);
if (t->ti_client != (ClientData)GDS_PENDING) continue;
t->ti_client = (ClientData)GDS_PROCESSED;
if (TiGetClientINT(t) != GDS_PENDING) continue;
TiSetClientINT(t, GDS_PROCESSED);

split_type = -1;
if (IsSplit(t))
10 changes: 5 additions & 5 deletions calma/CalmaWriteZ.c
Original file line number Diff line number Diff line change
@@ -124,8 +124,8 @@ extern void calmaOutR8Z(double d, gzFile f);
#define GDS_PROCESSED 1

#define PUSHTILEZ(tp) \
if ((tp)->ti_client == (ClientData) GDS_UNPROCESSED) { \
(tp)->ti_client = (ClientData) GDS_PENDING; \
if (TiGetClient(tp) == GDS_UNPROCESSED) { \
TiSetClientINT(tp, GDS_PENDING); \
STACKPUSH((ClientData) (tp), SegStack); \
}

@@ -1898,7 +1898,7 @@ calmaMergePaintFuncZ(
BoundaryTop *bounds = NULL;

/* Quick check for tiles that have already been processed */
if (tile->ti_client == (ClientData)GDS_PROCESSED) return 0;
if (TiGetClientINT(tile) == GDS_PROCESSED) return 0;

if (SegStack == (Stack *)NULL)
SegStack = StackNew(64);
@@ -1907,8 +1907,8 @@ calmaMergePaintFuncZ(
while (!StackEmpty(SegStack))
{
t = (Tile *) STACKPOP(SegStack);
if (t->ti_client != (ClientData)GDS_PENDING) continue;
t->ti_client = (ClientData)GDS_PROCESSED;
if (TiGetClientINT(t) != GDS_PENDING) continue;
TiSetClientINT(t, GDS_PROCESSED);

split_type = -1;
if (IsSplit(t))
Loading