From bc5a4a0fb1b3d697b1bb842d8f57a9f382addb8e Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Mon, 17 Feb 2025 09:49:04 +0000 Subject: [PATCH] Plow() pass by-pointer const TileTypeBitMask* instead of by-value sizeof(TileTypeBitMask) == 32 --- plow/PlowCmd.c | 2 +- plow/PlowMain.c | 11 ++++++----- plow/PlowRandom.c | 2 +- plow/PlowTest.c | 2 +- plow/plow.h | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/plow/PlowCmd.c b/plow/PlowCmd.c index 73120fe2..3febd5d3 100644 --- a/plow/PlowCmd.c +++ b/plow/PlowCmd.c @@ -212,7 +212,7 @@ wrongNumArgs: layers = cmd->tx_argc == 2 ? "*,l,subcell,space" : cmd->tx_argv[2]; if (!CmdParseLayers(layers, &mask)) break; - if (Plow(editDef, &editBox, mask, dir)) + if (Plow(editDef, &editBox, &mask, dir)) break; TxPrintf("Reduced plow size to stay within the boundary.\n"); diff --git a/plow/PlowMain.c b/plow/PlowMain.c index 47a6ee94..0e7a3dba 100644 --- a/plow/PlowMain.c +++ b/plow/PlowMain.c @@ -483,13 +483,13 @@ PlowSelection(def, pdistance, direction) */ bool -Plow(def, userRect, layers, direction) - CellDef *def; /* Cell being plowed */ - Rect *userRect; /* The plow. Interpreted as per direction +Plow( + CellDef *def, /* Cell being plowed */ + Rect *userRect, /* The plow. Interpreted as per direction * below. */ - TileTypeBitMask layers; /* The initial plow only sees these layers */ - int direction; /* One of GEO_NORTH, GEO_SOUTH, GEO_WEST, + const TileTypeBitMask *layersp,/* The initial plow only sees these layers */ + int direction) /* One of GEO_NORTH, GEO_SOUTH, GEO_WEST, * or GEO_EAST. */ { @@ -497,6 +497,7 @@ Plow(def, userRect, layers, direction) extern int plowWidthNumCalls; extern int plowWidthNumChoices; #endif /* COUNTWIDTHCALLS */ + TileTypeBitMask layers = *layersp; /* TTMaskCopy(&layers, layersp) */ TileTypeBitMask lc; Rect changedArea; bool firstTime; diff --git a/plow/PlowRandom.c b/plow/PlowRandom.c index 89afa018..56615658 100644 --- a/plow/PlowRandom.c +++ b/plow/PlowRandom.c @@ -118,7 +118,7 @@ PlowRandomTest(def) dir = plowGenRandom(0, 3); plowDir = dirs[dir]; plowGenRect(&def->cd_bbox, &plowRect); - (void) Plow(def, &plowRect, DBAllTypeBits, plowDir); + (void) Plow(def, &plowRect, &DBAllTypeBits, plowDir); TxPrintf("%s %d %d %d %d\n", dirnames[dir], plowRect.r_xbot, plowRect.r_ybot, plowRect.r_xtop, plowRect.r_ytop); diff --git a/plow/PlowTest.c b/plow/PlowTest.c index 37f2feae..3dd4454e 100644 --- a/plow/PlowTest.c +++ b/plow/PlowTest.c @@ -207,7 +207,7 @@ PlowTest(w, cmd) okTypes = DBAllTypeBits; if (cmd->tx_argc > 3 && !CmdParseLayers(cmd->tx_argv[3], &okTypes)) return; - if (!Plow(def, &editArea, okTypes, dir)) + if (!Plow(def, &editArea, &okTypes, dir)) { TxPrintf("Reduced plow size since we ran into the barrier.\n"); GeoTransRect(&EditToRootTransform, &editArea, &rootBox); diff --git a/plow/plow.h b/plow/plow.h index 57086b45..6ee61ffd 100644 --- a/plow/plow.h +++ b/plow/plow.h @@ -30,7 +30,7 @@ extern int PlowDRCInit(), PlowDRCFinal(); extern bool PlowDRCLine(); /* Called by CmdPlow() */ -extern bool Plow(); +extern bool Plow(CellDef *def, Rect *userRect, const TileTypeBitMask *layersp, int direction); /* Debugging command procedure */ extern int PlowTest();